CnPack Forum


 
cacausia
新警察
Rank: 1



UID 40588
Digest Posts 0
Credits 4
Posts 1
点点分 4
Reading Access 10
Registered 2008-6-21
Status Offline
Post at 2008-6-22 00:24  Profile | Blog | P.M. 
菜鸟求助

我想用双变量查询,可是怎么也不行?
sql.add('select 姓名 from shujukeming where '+cxzd+' like''''%'+cxnr+'%''');
cxzd   cxnr都是变量,应该怎么改?
Top
bahamut8348
灌水司司长
Rank: 6Rank: 6


UID 4743
Digest Posts 14
Credits 337
Posts 79
点点分 337
Reading Access 10
Registered 2007-1-18
Status Offline
Post at 2008-6-22 10:53  Profile | Blog | P.M. 


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;

注意单引号的个数




做人要厚道,看帖要回贴
Top
 




All times are GMT++8, the time now is 2024-11-24 10:54

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007989 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP