如何运行数据集查询? [英] how to run query on dataset?
问题描述
我有一个的DataSet
名为的DSView
包含的数据。下面是我用来读取XML的代码:
I have a DataSet
named dsView
that contains data. Here is the code i use to read the XML:
dsView = new DataSet();
dsView.ReadXml(@"\c:MyXml.xml");
数据有一个表名为 MEN
与田 FNAME
和 LNAME
。我如何运行这个的DSView
查询?
The data has a table named MEN
with fields Fname
and Lname
. How do I run a query on this dsView
? (for example: select * from MEN where Fname = 'zz'
)
推荐答案
您无法运行完整的SQL语句的的DataSet
- 但数据表
里面的数据集
确实有一个叫选择(串)
它选择的DataRow
的数组对象的方法那场比赛有一定的标准。
You cannot run complete SQL statements on a DataSet
- but the DataTable
inside your DataSet
does have a method called Select(string)
which selects an array of DataRow
object that match a certain criteria.
检查出的在数据表 MSDN文档
Check out the MSDN docs on DataTable
您可能会需要像做(未经测试):
You would probably have to do something like (untested):
DataTable tblMEN = dsView.Tables["MEN"];
DataRow[] results = tblMen.Select("Fname = 'zz'");
这篇关于如何运行数据集查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!