比如,以下程序段:
procedure TForm1.Button2Click(Sender: TObject);
var
astr: string ;
begin
adoquery1.Close ;
adoquery1.SQL.Clear;
astr:='select * from table1 where field1 like '%王%' ';
adoquery1.SQL.add(astr);
try
adoquery1.Open ;
except
adoquery1.ExecSQL;
end;
end;
end. 为了查询字段中含有“王”的记录,都是单引号,系统没办法区分!
我用的是sql server 2000.
procedure TForm1.Button2Click(Sender: TObject);
var
astr: string ;
begin
adoquery1.Close ;
adoquery1.SQL.Clear;
astr:='select * from table1 where field1 like '%王%' ';
adoquery1.SQL.add(astr);
try
adoquery1.Open ;
except
adoquery1.ExecSQL;
end;
end;
end. 为了查询字段中含有“王”的记录,都是单引号,系统没办法区分!
我用的是sql server 2000.
解决方案 »
- 求檢測WINDOWS API有沒被HOOK的例子代碼
- 高分求助:关于线程中使用Synchronize的问题!
- 我要做一个字段查询的模块,请问写代码怎样才能不出错误?
- 如何控制不同的的程序为当前程序(100分求解)?
- mdi窗体问题,很简单的。
- 谁能给我推荐一个能编辑256色以上的res资源编辑器?
- 小女子在这向各位大吓们请教一个问题
- DBGrid中我选中多行,然后我想只显示或报表打印我选中的这些记录的结果,应该怎么做.
- 如何编程实现通过一台计算机,关闭或重启另一台计算机?
- 在delphi 中如何实现存储
- intraweb能不能发EMAIL?
- 关于使用DBEXPRESS访问SQLSERVER中带参数的存储过程
或者干脆这样:
astr:='select * from table1 where field1 like '+''''+'%王%'+'''';
begin
if key=#13 then
begin
if flatedit1.Text='' then
application.MessageBox('您没有输入关键字!','给您的提示',mb_ok+MB_ICONEXCLAMATION )
else
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from 内容 where 内容 like :aa');
adoquery1.Parameters.ParamByName('aa').Value:='%'+flatedit1.Text+'%';
adoquery1.Open;
showmessage('找到满足条件的记录数: '+inttostr(adoquery1.RecordCount)+'条');
flatedit1.Text:='';
end;
end;