如何运行数据集查询? [英] how to run query on dataset?

查看:131
本文介绍了如何运行数据集查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆