Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > getting row count
 

getting row count

I am currently using the code below to retrive the total row in my table. The problem is that I need to create a datagridview on the form in order to calculate the count. So is there anyway to store maybe a memory table so I don't need to have a datagridview around the form?Thank you.

Dim sqlstr As String = "select * from plgcuta "
Dim connection As New SqlConnection(connectionString)
da = New SqlDataAdapter(sqlstr, connection)
dgv.DataSource = ds.Tables(0)

dim count as integer = dgv.rows.count

lucashii  Tuesday, August 21, 2007 3:23 AM

You can use DataTable

dt.Rows.Count

Tamirro  Tuesday, August 21, 2007 7:40 AM

Hi, lucashii,

Based on my understanding, you want to get the row count of your returned DataSet, don't you.

I think Tamirro's idea is right, and to make the answer clear.

You can use

Code Snippet
Dim count As Integer = ds.Tables(0).Rows.Count

Hope this helps,

Regards

Yu Guo â€?MSFT  Thursday, August 23, 2007 10:37 AM

You can use DataTable

dt.Rows.Count

Tamirro  Tuesday, August 21, 2007 7:40 AM

Hi, lucashii,

Based on my understanding, you want to get the row count of your returned DataSet, don't you.

I think Tamirro's idea is right, and to make the answer clear.

You can use

Code Snippet
Dim count As Integer = ds.Tables(0).Rows.Count

Hope this helps,

Regards

Yu Guo â€?MSFT  Thursday, August 23, 2007 10:37 AM

You can use google to search for other answers

Custom Search

More Threads

• Expression frustration
• ListBox.Items.Add() takes object not string why?
• problem with bindingnavigator and multiple tables
• slow datagridview painting
• InvalidCastException in DataGrid
• Typed DataSet, Binding to a DataRow and DBNull
• databinding in datagrid takes lot of virtual memory
• copy the data in ado.net
• how do I bind a dataset to a combobox?
• databinding to a multiline textbox