with adoquery1 do
begin
close;
clear;
sql.add('select * from table1 where table1.co1 like "%:aa%"');
parameters.ParamByName('aa').value=edit1.text;
open;
end;
begin
close;
clear;
sql.add('select * from table1 where table1.co1 like "%:aa%"');
parameters.ParamByName('aa').value=edit1.text;
open;
end;
sql.add('select * from table1 where table1.co1 like %:aa%');
你的这句会变成select * from table1 where table1.co1 like %'abcd'%
你说会对吗?
begin
close;
clear;
sql.add('select * from table1 where co1 like "%'+edit1.text+'%"');
open;
end;
其中的table1.co1写成col就可以了
CoolSlob(),一点点~~~
parameters.ParamByName('aa').AsString=edit1.text;
project project1.exe raised exception class eoleexception with
message 'invalid column name '%n%'',process stopped,use step or run
to continue!
这是什么意思,哪位高手可以帮帮我!
aa为string类型变量var str,aa:string;aa:=edit1.text;
str:='select * from table1 where table1.co1 like%:'+aa+'%';with adoquery1 do
begin
close;
clear;
sql.add(str);
open;
end;这种情况更本不能使用ParamByName('aa').这样的语句
1.with adoquery1 do
begin
close;
clear;
sql.add('select * from table1 where col like ''%'+edit1.text
+'%''');
open;
end;
2.另一种在flyingice(ygxdha)方法上改进一下:
var
aa,str:string;
aa:=edit1.text;
str:='select * from table1 where col like ''%'+aa+'%''';
with adoquery1 do
close;
clear;
sql.add(str);
open;
end;
这种情况我们通常是使用format函数的。
with adoquery1 do
begin
close;
sql.Clear;
sql.add('select * from table1 where table1.co1 like :aa');
parameters.ParamByName('aa').value:='%'+(edit1.Text)+'%'
open;
end;