Subject: 菜鸟求助 [Print This Page]
Author:
cacausia Time: 2008-6-22 00:24 Subject: 菜鸟求助
我想用双变量查询,可是怎么也不行?
sql.add('select 姓名 from shujukeming where '+cxzd+' like''''%'+cxnr+'%''');
cxzd cxnr都是变量,应该怎么改?
Author:
bahamut8348 Time: 2008-6-22 10:53
var
ColumnName, Value: string;
begin
ColumnName:= 'your Column Name';
Value:= '...';
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT * FROM TabelName WHERE ' + ColumnName + ' LIKE ''%' + Value + '%''');
ADOQuery1.Open;
end;
注意单引号的个数
Welcome to CnPack Forum (http://bbs.cnpack.org/) |
Powered by Discuz! 5.0.0 |