首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

能不能查询combobx是否有某个数据集解决思路

2012-05-27 
能不能查询combobx是否有某个数据集combobox1ab表EMPnameabcd想实现select name from EMP where name in c

能不能查询combobx是否有某个数据集
combobox1
a
b

表EMP
name
a
b
c
d



想实现 select name from EMP where name in combobox1.text


结果是
a
b




[解决办法]
什麼數據庫?自己循環combobox拼接成in('',''),這樣的格式就行了啊
[解决办法]
MSSQL:

Delphi(Pascal) code
s:=quotedstr(','+combobox1.Items.CommaText+',');ADOQuery1.SQL.Text:='select [name] from EMP where charindex('',''+name+'','', '+s+')>0';
[解决办法]
Procedure TForm1.BitBtn1Click(Sender: TObject);
Var
I: Integer;
S: String;
Begin
With ADOQuery1, ComboBox1 Do
Begin
For I := 0 To Items.Count - 1 Do
Begin
If I = 0 Then
S := QuotedStr(Items[I])
Else
S := S + ' , ' + QuotedStr(Items[I]);
End;

SQL.Clear;
SQL.Add(Format('SELECT * FROM bbb WHERE NM IN (%s);', [S]));

Application.MessageBox(Pchar(SQL.Text), 'sql', 64);

Open;
End;
End;
[解决办法]
仔细看清楚3#楼where后面是什么!!!!!

热点排行