如何过滤数据视图
我有一个包含表列表的数据视图。我正在读取一个值列表,然后我想将其作为过滤器应用于此数据视图。值列表实际上是“table1、table2、table3”的形式。所以我想我可以使用它作为我的数据视图的过滤器。
SqlOp.CommandText = "select name from dbo.sysobjects where xtype='u'";
SqlOp.ExecuteDataReader();
DataView dv = SqlOp.GetDataAsDataView();
SqlOp.CloseConnection();
返回数据视图中所有表的列表。关于如何过滤此数据视图有任何帮助吗?
编辑:
不确定我是否完全清楚我想要实现的目标。为了澄清,我试图弄清楚 .RowFilter
如何/是否可以帮助我过滤此数据视图。像这样的东西:
dv.RowFilter = "name IN (table1, table2, table3)" // I know this doesn't work
I have a dataview that contains a list of tables. I am reading in a list of values that I then want to apply as a filter to this dataview. The list of values is actually in the form of "table1, table2, table3". So I thought I would be able to use this as a filter on my dataview.
SqlOp.CommandText = "select name from dbo.sysobjects where xtype='u'";
SqlOp.ExecuteDataReader();
DataView dv = SqlOp.GetDataAsDataView();
SqlOp.CloseConnection();
Returns a list of all the tables in a dataview. Any help on how to filter this dataview?
Edit:
Not sure if I was completely clear in what I seek to accomplish. To clarify, I am trying to figure out how/if .RowFilter
will help me in filtering this dataview. Something like:
dv.RowFilter = "name IN (table1, table2, table3)" // I know this doesn't work
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用 like 语句
以及使用参数集合
更多向 SqlCommand .NET 添加参数的有效方法
You have to use like statement
As well use Parameters collection
More Efficient Way of Adding Parameters to a SqlCommand .NET
我找出了
.RowFilter
问题:I figured out the
.RowFilter
issue: