发布网友 发布时间:12小时前
共2个回答
热心网友 时间: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+'%''';
热心网友 时间:12小时前
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;