delphi运行错误——like 附近有语法错误??procedure TForm1.BitBtn6Cli...
发布网友
发布时间:2024-10-29 08:07
我来回答
共2个回答
热心网友
时间:2024-10-29 08:12
呵呵,,你后边的like 拼接的没有错,但是这句sql并不是因为like哪儿的问题.
//首先在where前面加个空格.不然拼一块的话就会连在一块,会出错
swtest:=' WHERE fault_message like '+'''%'+comboBox2.text+'%''';
//这里的'sql'应该是个变量吧... ?? 不然这就不是一个完整的sql语句了.
sqltest:='sql'+swtest;
建议修改:
swtest:='select * from tableXXX';
swtest:=swtest+' WHERE fault_message like '+'''%'+comboBox2.text+'%''';
热心网友
时间:2024-10-29 08:16
adoname.Close;
adoname.SQL.Clear;
adoname.Parameters.Clear;
adoname.SQL.Add('select * from '+ tablename +' where '+ ziduan1 + ' like''%'+ trim(likename) + '%'' ');
if trim(ziduan2)<>'' then adoname.SQL.Add('or '+ ziduan2+' like ''%'+ trim(likename) +'%'' ');
if trim(ziduan3)<>'' then adoname.SQL.Add('or '+ ziduan3+' like ''%'+ trim(likename) +'%'' ');
if trim(ziduan4)<>'' then adoname.SQL.Add('or '+ ziduan4+' like ''%'+ trim(likename) +'%'' ');
if trim(ziduan5)<>'' then adoname.SQL.Add('or '+ ziduan5+' like ''%'+ trim(likename) +'%'' ');
if trim(ziduan6)<>'' then adoname.SQL.Add('or '+ ziduan6+' like ''%'+ trim(likename) +'%'' ');
adoname.Open;