Dataset top n lines in c #

I want to select the top N rows from a dataset. is there any way to do this in c #? I do not have access to SQL Server stored procedures to modify them, so I only need to show some data binding strings.

how would i do that?

+4
source share
3 answers

If you are using 3.5 framework, then first enter datatable (dt) and then use the bottom line -

dt.Rows.Cast<System.Data.DataRow>().Take(n) 
+10
source

Using the DataAdapter.Fill method, we can implement paging in sqlserverce 3.0

 string Query = "Select * From WorkOrderDetails order by AssetID ASC"; SqlCeDataAdapter da = new SqlCeDataAdapter(Query, strConString); DataTable dt = new DataTable(); //da.Fill(startIndex, endIndex, dt); da.Fill(startIndex, 100, dt); dataGrid1.DataSource = dt; 
+1
source
 string Query = "Select * From WorkOrderDetails order by AssetID ASC"; SqlCeDataAdapter da = new SqlCeDataAdapter(Query, strConString); DataTable dt = new DataTable(); //da.Fill(startIndex, endIndex, dt); da.Fill(startIndex, 100, dt); dataGrid1.DataSource = dt; 
0
source

All Articles