Answered by:
Count number of records in a dataset

Question
-
Is there a way to have a count of the records in a dataset show up in a label on a form?Friday, August 14, 2009 6:00 PM
Answers
-
Yes and No. Mainly No.
It is easy to count the number of records---or rows---in a table, but a DataSet may contain multiple tables in its' Tables property.
Mark the best replies as answers. "Fooling computers since 1971."- Marked as answer by Jeff Shan Tuesday, August 18, 2009 2:44 AM
Friday, August 14, 2009 6:03 PM -
Dim ds As New System.Data.DataSet ds.Tables.Count ds.Tables(0).Rows.Count ds.Tables(0).Columns.Count
1. Returns the number of tables in the dataset
2.returns the number of rows in datatable 1
3.returns the number of columns in datatable 1
KennethFriday, August 14, 2009 8:13 PM -
you can use the information kenneth gave you in conjunction with a loop to get the count for all tables in the dataset if that is what you are after.
a dataset is a collection of tables and the tables each have a collection of rows.
something like this:
dim rwcnt as integer
for each table as datatable in yourdataset.tables
rwcnt += table.rows.count
next
FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial- Marked as answer by Jeff Shan Tuesday, August 18, 2009 2:44 AM
Saturday, August 15, 2009 3:17 AM
All replies
-
Yes and No. Mainly No.
It is easy to count the number of records---or rows---in a table, but a DataSet may contain multiple tables in its' Tables property.
Mark the best replies as answers. "Fooling computers since 1971."- Marked as answer by Jeff Shan Tuesday, August 18, 2009 2:44 AM
Friday, August 14, 2009 6:03 PM -
Dim ds As New System.Data.DataSet ds.Tables.Count ds.Tables(0).Rows.Count ds.Tables(0).Columns.Count
1. Returns the number of tables in the dataset
2.returns the number of rows in datatable 1
3.returns the number of columns in datatable 1
KennethFriday, August 14, 2009 8:13 PM -
you can use the information kenneth gave you in conjunction with a loop to get the count for all tables in the dataset if that is what you are after.
a dataset is a collection of tables and the tables each have a collection of rows.
something like this:
dim rwcnt as integer
for each table as datatable in yourdataset.tables
rwcnt += table.rows.count
next
FREE DEVELOPER TOOLS, CODE & PROJECTS at www.srsoft.us Database Code Generator and Tutorial- Marked as answer by Jeff Shan Tuesday, August 18, 2009 2:44 AM
Saturday, August 15, 2009 3:17 AM -
Well Mostly NoSaturday, August 15, 2009 9:08 PM