Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

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

http://www.w3schools.com/sql/sql_where.asp[^]
 
Share this answer
 
If you cannot restrict the rows at DB Query level.
Try LINQ on Datatable

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


Hope this Helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900