Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3) And (ShuLiang > 0) And (ChanPin Like %s%) And (TingYong = 0)出错提示:变量或者类型不正确,或者不在可以接受范围之内,要不就是与其它数据冲突.不知有没有解决办法???
Filter := '((Fl_Auto_ID = 1) or (Fl_Auto_ID = 2) or (Fl_Auto_ID = 3)) And (ShuLiang > 0) And (ChanPin Like ‘%s%‘) And (TingYong = 0)
经你个过滤事件的例子 The following example shows how to use a field comparison when filtering records on a local table, by using the OnFilterRecord event.procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);begin Accept := DataSet['DateOfPayment'] > DataSet['DateOfPurchase'] + 30;end;
现在结贴: 问题解决: 使用OnFilterRecord + Filter OnFilterRecord : Accept := (DataSet['ShuLiang'] > 0) And (Pos('s', DataSet['ChanPin']) > 0) And (DataSet['TingYong'] = 0) Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3)' 这个Fl_Auto_ID 的值是多个的:0..N个 注:这四个条件是变化的,当然这四个条件也可以用SQL我是想使用Filter是不是比较快些,不过技术不到家,还是不行的
Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3) And (ShuLiang > 0) And (ChanPin Like '''%s%''') And (TingYong = 0)';
Filtecd := true;
試試
Filtecd := false;
Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3) And (ShuLiang > 0) And (ChanPin Like ''%s%'') And (TingYong = 0)';
Filtecd := true;
这样也是出错的Filter := 'Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3'
这样是不会错的Filter := 'Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3 And ShuLiang > 0'
这样会出错的Filter := '(KcShuLiang > 0) And (TingYong = 0) And Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3'
这样是不会错, 但是我的原意是满足Fl_Auto_ID = (1,2,3) 同时加入其它条件
这样也是出错的应该改成:
Filter := '((Fl_Auto_ID = 1) or (Fl_Auto_ID = 2) or (Fl_Auto_ID = 3)) And (ShuLiang > 0) And (TingYong = 0)'
还是两样还是不行的
出错提示:变量或者类型不正确,或者不在可以接受范围之内,要不就是与其它数据冲突.
Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3) And (ShuLiang > 0) And (ChanPin Like '+''''+%s%+''''+') And (TingYong = 0)';
Filtecd := true;
这方面看一本基本的数据库入门书一定有的·
楼主还是看看书吧,就算你问出结果了,也没有系统化学习啊,书上讲了原理和事件的其他用法的
Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3) And (ShuLiang > 0) And (ChanPin Like'+QuotedStr('%s%')+' And (TingYong = 0)
Filtered := True;如再有问题,提示过滤条件中是不能存在lookup字段
可以试试的是在每个等式两边都加上括号,该是用数字的地方就用数字,该用字符串的地方用字符串(字段名跟后面的数值类型进行比较时一定要保证两者类型相同),再注意一下逻辑问题,应该没有什么问题。比如:
Filter := '(DateTime>' + '''2003-11-16 14:00:00''' + ')and(IncomeType like' + '''%我%'''+ ')'
The following example shows how to use a field comparison when filtering records on a local table, by using the OnFilterRecord event.procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);begin
Accept := DataSet['DateOfPayment'] > DataSet['DateOfPurchase'] + 30;end;
问题解决: 使用OnFilterRecord + Filter
OnFilterRecord :
Accept := (DataSet['ShuLiang'] > 0) And (Pos('s', DataSet['ChanPin']) > 0)
And (DataSet['TingYong'] = 0)
Filter := '(Fl_Auto_ID = 1 or Fl_Auto_ID = 2 or Fl_Auto_ID = 3)'
这个Fl_Auto_ID 的值是多个的:0..N个
注:这四个条件是变化的,当然这四个条件也可以用SQL我是想使用Filter是不是比较快些,不过技术不到家,还是不行的