起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 158|回复: 2

【结贴】[请求]关于数据集参数过滤的问题**

[复制链接]
发表于 2008-5-9 09:05:59 | 显示全部楼层 |阅读模式
我看来http://bbs.justep.com/forum.php? ... =590这个帖子:
二、因为 SQLFilter (或者 UserFilter)是服务器端过滤,而 Filter 是客户端过滤的。服务器端是可以处理参数,客户段是不可以的。就是说当你设置了SQLFilter 属性并且 SQLFiltered =True 以后,会把 SQLFilter 和 SQL语句共同来组成 SQL 语句发给数据库服务器。因此可以支持参数。
但是我这里用SQLFilter传参数怎么就不行呢?
例:with TSQLDataSet(dsbMatCode.DataSet) do
  begin
    DisableControls;
    //if Active then Close;
    //Sql.Text:='Select * from MMS_MatCode where 1=1 '+FsFilterClass+FsFilterOther + FsFilterFind+'';
    SQLFiltered := False;   
    SQLFilter := '1=1 ' + FsFilterClass + FsFilterOther + FsFilterFind;
    if not (edtMatcode.Text='') then Params.ParamByName('Matcode').AsString := '%'+edtMatcode.Text.Trim+'%';
    if not (edtMatName.Text='') then Params.ParamByName('MatName').AsString := '%'+edtMatName.Text.Trim+'%';
    if not (edtMatType.Text='') then Params.ParamByName('MatType').AsString := '%'+edtMatType.Text.Trim+'%';
    if not (edtAidCode.Text='') then Params.ParamByName('Aidcode').AsString := '%'+SysUtils.UpperCase(edtAidCode.Text.Trim)+'%';
    SQLFiltered := True;
    //Open;
    EnableControls;
end;
调试时执行到SQLFilter时值为:MatCode like :MatCode
再继续执行赋参数值的时候就报错提示:paramter MatCode not found
求助啊!
回复

使用道具 举报

发表于 2008-5-9 09:48:46 | 显示全部楼层
再sqlfilter中如何使用定义的参数可以参考一下下面的帖子:
http://bbs.justep.com/forum.php? ... ilter%2Aparambyname
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-5-9 12:44:43 | 显示全部楼层
OK,结贴
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-12 14:45 , Processed in 0.040751 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表