delphi运行错误——like 附近有语法错误??procedure TForm1.BitBtn6Click(Sender: TObject);
接触编程不久,菜鸟一个,照猫画虎!!!诚请高手指点,小女子不胜感激!拜谢!procedureTForm1.BitBtn6Click(Sender:TObject);var...
接触编程不久,菜鸟一个,照猫画虎!!!诚请高手指点,小女子不胜感激!拜谢!
procedure TForm1.BitBtn6Click(Sender: TObject);
var
sqltest,swtest:string;
begin
swtest:='WHERE fault_message like '+'''%'+comboBox2.text+'%''';
sqltest:='sql'+swtest;
if adoquery1.active then adoquery1.close;
begin
adoquery1.sql.Clear;
ADOquery1.sql.add(sqltest);
adoquery1.Active:=true;
listbox1.Items.Clear;
listbox2.items.clear;
with ADOquery1 do
begin
first;
while not Eof do
begin
listbox1.Items.Add(FieldByName('possible_cause').AsString);
listbox2.items.add(fieldbyName('method').asstring);
Next;
end;
end;
end;
end; 展开
procedure TForm1.BitBtn6Click(Sender: TObject);
var
sqltest,swtest:string;
begin
swtest:='WHERE fault_message like '+'''%'+comboBox2.text+'%''';
sqltest:='sql'+swtest;
if adoquery1.active then adoquery1.close;
begin
adoquery1.sql.Clear;
ADOquery1.sql.add(sqltest);
adoquery1.Active:=true;
listbox1.Items.Clear;
listbox2.items.clear;
with ADOquery1 do
begin
first;
while not Eof do
begin
listbox1.Items.Add(FieldByName('possible_cause').AsString);
listbox2.items.add(fieldbyName('method').asstring);
Next;
end;
end;
end;
end; 展开
2个回答
展开全部
呵呵,,你后边的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+'%''';
//首先在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+'%''';
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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;
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;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询