积极答复者
BindingSource filter 中使用函数的问题.

问题
-
例子:
bindingsource.datasource = dataset1
bindingsource1.filter = "month(日期型字段)=2 and day(日期型字段)=20"我在使用bindingsource的时候, filter中字段类型为日期型,对这个字段使用过滤的时候我使用了month 和 day 函数, 系统提示不识别这个函数.
在SQL中这个函数是可以用的,那么在filter中应该怎么用呢?
人要诚实!还要踏实! 我先为人人,人人再为我! 我的Spaces: http://mydodu.spaces.live.com/- 已移动 Sheng Jiang 蒋晟Moderator 2010年3月24日 21:37 System.Windows.Forms (发件人:Visual Studio 相关讨论)
答案
-
BindingSource本身并没有实现过滤,过滤是通过调用调用数据源的IBindingListView::Filter实现的。看起来数据源不支持这两个函数。建议采用其他的过滤方式,例如将过滤条件直接传递给数据源。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
Visual C++ MVP- 已标记为答案 YiChun Chen 2010年3月26日 11:27
-
你把条件改一下如: 日期型字段 >= '2010-02-20 00:00:00' and 日期型字段 <= '2010-02-20 23:59:59'
知识改变命运,奋斗成就人生!- 已标记为答案 YiChun Chen 2010年3月26日 11:27
全部回复
-
BindingSource本身并没有实现过滤,过滤是通过调用调用数据源的IBindingListView::Filter实现的。看起来数据源不支持这两个函数。建议采用其他的过滤方式,例如将过滤条件直接传递给数据源。
The following is signature, not part of post
Please mark the post answered your question as the answer, and mark other helpful posts as helpful.
Visual C++ MVP- 已标记为答案 YiChun Chen 2010年3月26日 11:27
-
你把条件改一下如: 日期型字段 >= '2010-02-20 00:00:00' and 日期型字段 <= '2010-02-20 23:59:59'
知识改变命运,奋斗成就人生!- 已标记为答案 YiChun Chen 2010年3月26日 11:27
-
我现在的方法是直接在执行查询数据的时候加上去的条件,难道只能这样吗? 对于日期型字段就没有其他办法了吗?
X.X.Y 说的不是没有道理,可我觉得你这样未免有些牵强.
人要诚实!还要踏实! 我先为人人,人人再为我! 我的Spaces: http://mydodu.spaces.live.com/