要求查询:
Select * from myTable
where myField like %什么%注意:
1、上面的“什么”是任意的
2、AdoDataset 必须是用
Parameters.ParamByName 的方式赋值给这个参数我试过:
1、
adoDataset.commandtext:=' Select * from myTable where myField like %:什么%';
adoDataset.Parameters.ParamByName('什么').value:='test'
系统提示找不到此参数2、
adoDataset.commandtext:=' Select * from myTable where myField like :%什么%';
adoDataset.Parameters.ParamByName('%什么%').value:='test'
系统不出错,但找不到任何记录3、有在虾可能会说,用
' ... and StudentName like ''%' + edtStudentName.Text + '%''';
的形式解决,但是一旦要查询的是单引号' 时,将会出错。
请各位帮忙解决!注意,要用Parameters.ParamByName的方法!
在线等......
Select * from myTable
where myField like %什么%注意:
1、上面的“什么”是任意的
2、AdoDataset 必须是用
Parameters.ParamByName 的方式赋值给这个参数我试过:
1、
adoDataset.commandtext:=' Select * from myTable where myField like %:什么%';
adoDataset.Parameters.ParamByName('什么').value:='test'
系统提示找不到此参数2、
adoDataset.commandtext:=' Select * from myTable where myField like :%什么%';
adoDataset.Parameters.ParamByName('%什么%').value:='test'
系统不出错,但找不到任何记录3、有在虾可能会说,用
' ... and StudentName like ''%' + edtStudentName.Text + '%''';
的形式解决,但是一旦要查询的是单引号' 时,将会出错。
请各位帮忙解决!注意,要用Parameters.ParamByName的方法!
在线等......
解决方案 »
- delphi listview 显示大量数据的问题
- access数据库 中用count(iif()) 的问题?大家帮我
- delphi数据级联删除问题
- 请问这个是什么原因?编译运行,好象很多行没有被编译执行?
- 这家公司会不会是骗子?请过来人指点一下,这关系到我的前程
- 送分题~!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!!!!!!!!~~~~~~~~~~~~~!~~~~~~~~!
- 请教Raptor(猛禽)同志:如果通过SocketConnect创建COM+组件接口,该COM+组件不是从IAppServer继承而来.
- 请教一个小问题,帮看看阿
- 三层结构+SQL Server2000的数据库发布
- 一个低级的问题
- 怎样通过HTTP代理下载FTP或者BT,玩游戏等?
- 国庆归来,散100分先。
adoDataset.commandtext:=' Select * from myTable where myField like :fld';
adoDataset.Parameters.ParamByName('fld').value:='%test什么%';
如果用上面的方法,
这样能查出记录,但是有问题:
如果我查找的东西是
%那么系统会把所有的东西都显示出来。
这有点像以前有的BBS上提到的登录BUG。
begin
s := 'test';
adoDataset.Parameters.ParamByName('%什么%').value:='%'+s+'%'
end;
如果s为空则会查询出所有。