如何使用关键字“IN”来使用 DataView 的 RowFilter过滤集合
我想过滤数据视图中填充的集合。我为此使用的控件是多选复选框组合框。由此返回的字符串是“val1,val2,val3”。然后我将其传递给 sql 查询语句,以便能够用作我的 FilterExpression。但是,当将我的表达式分配给 dataView.RowFilter = SomethingFilterString 时,其中我的表达式为 Something IN (val1, val2, val3) ,会出现错误,指出找不到列 val1。有谁可以帮忙吗???
I would like to filter a collection populated in a DataView. The control I am using for this is a multi-select checkbox Combobox. The string returned from this is 'val1, val2, val3'. I then pass this to a sql query statement so as to be able to use as my FilterExpression. However,when assigning my expression to dataView.RowFilter = somethingFilterString which has my expression as Something IN (val1, val2, val3) is gives an error that it cannot find column val1. Anyone that can help please????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
val1、val2、val3
的值是字符串(例如,“apples、pears、bananas”
),那么您需要查询文本来显示它们是字符串,否则必须假设它们是列名。如果您正在构建像这样的逗号分隔列表:
...那么您可以执行类似的操作来获取带引号的值:
If the values of
val1, val2, val3
are strings (eg,"apples, pears, bananas"
), then you need the query text to show they are strings otherwise it has to assume they are column names.If you're building the comma-separated list like so:
... then you could do something like this to get the values with quotes instead: