with datamodule1.qry_bdcx do
begin
close;
sql.Clear ;
sql.Add('select * from xsbd where xsxh_id=:id '+'''%''');//报错
parambyname('id').AsString:=edit1.text;
open;
end;原意是想:select * from table where xsxh_id=id%
其中id是变量 在delphi中应该怎么写啊?????????????
begin
close;
sql.Clear ;
sql.Add('select * from xsbd where xsxh_id=:id '+'''%''');//报错
parambyname('id').AsString:=edit1.text;
open;
end;原意是想:select * from table where xsxh_id=id%
其中id是变量 在delphi中应该怎么写啊?????????????
illegal character in input file '%'
%是干甚的?
比如说 id%
当id=’张‘时 只要是姓张的人都被检索出来了!!!
illegal character in input file '%'
parambyname('id').AsString:=trim(edit1.text);
with datamodule1.qry_bdcx do
begin
close;
sql.Clear ;
sql.Add('select * from xsbd where xsxh_id like '+'''+Trim(Edit1.Text)+'%'+''');
open;
end;
試一下。
begin
close;
sql.Clear ;
sql.Add('select * from xsbd where xsxh_id like :id); //这里修改
parambyname('id').AsString:=edit1.text + '%';//这里加个%
open;
end;
可否满足你的要求?以下没有测试,你看行不行(请多指教)id:=edit1.text;
with datamodule1.qry_bdcx do
begin
close;
sql.Clear ;
sql.text:='select * from xsbd where xsxh_id like '''+'id%'+'''';
open;
end;
)没说清楚——我还以为你要48%,这里你应该用like而非=
so:
sql.add('select * from xsbd where xsxh_id like '+''''+edit1.text+'%'+'''');
刚才漏写几个'''',不好意思
这样一来就变成这样了select * from tabel where xsxh_id like 'id %'
SQL.Add('select * from xsbd where xsxh_id like '+''''+edit1.text+' %'+'''');
改成4个单引号,在delphi有时是3个,有时是4个,好好体会吧
可能是这样吧。
lvxq(吕歌) cailiantao(蔡练涛) 的版本能用其余的多报错为 illegal character in input file '%'谢谢