如何在c#中将sqlquery传递给datatable.select()? [英] How to pass sqlquery to datatable.select() in c#?

查看:192
本文介绍了如何在c#中将sqlquery传递给datatable.select()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



我遇到数据表问题(c#)。请给出你解决这个问题的建议。我的问题是,我有一个sqlquery(例如,从员工中选择id,name,location)。这里tablename,列是动态的)。我需要将此sqlquery传递给datatable,这个数据表具有巨大的记录和列。但我只想要那些特定的记录。



我怎样才能实现?请建议我。



先谢谢。



Satish Chandragiri。

解决方案

将where子句应用于查询以获取所需的记录集。



http://www.w3schools.com/sql/sql_where.asp [ ^ ]


如果您不能在DB Query级别限制行。

尝试LINQ on数据表



 var results = 来自 myRow  in  myDataTable.asEnumerable()
其中​​ results.Field( FieldNAme)== 1 // 其中语句表达式在这里。
选择结果;





希望这有助于。


Hello Everyone,

I am facing problem with datatable(c#). Kindly give u'r advice to solve this issue. My problem is, i am having one sqlquery(eg, select id, name, location from employee). Here tablename, columns are dynamic). I need to pass this sqlquery to datatable, this datatable having huge records& columns. But i want that particular records only.

How can i achieve? kindly suggest me.

Thanks in Advance.

Satish Chandragiri.

解决方案

Apply where clause to your query to fetch the required set of records.

http://www.w3schools.com/sql/sql_where.asp[^]


If you cannot restrict the rows at DB Query level.
Try LINQ on Datatable

var results = from myRow in myDataTable.asEnumerable()
where results.Field("FieldNAme") == 1 // your where statement expression goes here.
select results;



Hope this Helps.


这篇关于如何在c#中将sqlquery传递给datatable.select()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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