Select Top 10 in a dataTable???
-
Hi! I want to select only 10 rows from a dataTable each time, just as from a database("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID"). for example: DataTable myTable = new DataTable("orders"); DataRow[] rows = myTable.Select("TOP 10 ID < 100"); 1)How can I write the correct statement. 2)Can I ues "TOP" key word or there's other way to do it? Thank you very much.:rose:
-
Hi! I want to select only 10 rows from a dataTable each time, just as from a database("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID"). for example: DataTable myTable = new DataTable("orders"); DataRow[] rows = myTable.Select("TOP 10 ID < 100"); 1)How can I write the correct statement. 2)Can I ues "TOP" key word or there's other way to do it? Thank you very much.:rose:
I'm kinda new to this but this is how i did it. SqlCommand cmd = new SqlCommand(("SELECT TOP 10 FROM orders WHERE ID <100 ORDER BY ID",SQLConn); cmd.CommandType = CommandType.Text; SqlDataReader SQLData = cmd.ExecuteReader(); DataTable My_DataTable = SQLData.GetSchemaTable(); int iColumns = My_DataTable.Rows.Count; //shuld be 10 while(SQLData.Read()) { string sOut = ""; for(int i=0; i