Number of Records in A Dataset
-
I have successfully retrieved data with an adapter to create my required dataset. But now I want to know how many rows are in my dataset? I am using SQL 2003 and .NET1. I see that many people use the Tables.Rows.Count, but mine isn't working when I do that. How do I retrieve the number of rows of the table in the dataset? Thanks.
-
I have successfully retrieved data with an adapter to create my required dataset. But now I want to know how many rows are in my dataset? I am using SQL 2003 and .NET1. I see that many people use the Tables.Rows.Count, but mine isn't working when I do that. How do I retrieve the number of rows of the table in the dataset? Thanks.
-
please try the following code
dim ds as new dataset dim da as new sqldataadapter(strQuery,conn) da.fill(ds,"test") response.write(ds.tables("test").rows.count)
strQuery is the select command, conn is the connectionI don't know VB I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.
-
I don't know VB I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.
-
I don't know VB I'm using C#. Are you still able to help me in finding out how many records are in a table in a dataset.
//this should answer your question string connStr = "Fill in your connection string here"; string sqlStr = "SELECT * FROM someTable"; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn); System.Data.DataSet ds1 = new DataSet("test"); System.Data.DataTable dt1 = ds1.Tables["someTable"]; int rowCount = dt1.Rows.Count; //or a good use is for(int i=0; i< dt1.Rows.Count; i++) { //do something } //or another foreach (System.Data.DataRow dr1 in dt1.Rows) { //Do something else }
-
//this should answer your question string connStr = "Fill in your connection string here"; string sqlStr = "SELECT * FROM someTable"; System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr); System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(sqlStr, conn); System.Data.DataSet ds1 = new DataSet("test"); System.Data.DataTable dt1 = ds1.Tables["someTable"]; int rowCount = dt1.Rows.Count; //or a good use is for(int i=0; i< dt1.Rows.Count; i++) { //do something } //or another foreach (System.Data.DataRow dr1 in dt1.Rows) { //Do something else }
Thanks xvaughan