How do you count the number of records return when selecting the database with ExecuteReader()
ie.
myReader = mySelCommand.ExecuteReader()
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Hirendra SisodiyaPosted Mar 23, 2010, 2:11 AM
'you can fill datagridview in this way, try this:
Dim myReader As OleDb.OleDbDataReader = mySelCommand.ExecuteReader()
Dim columnCount As Integer = myReader.FieldCount
Dim rowData As String() = New String(columnCount - 1)
For i As Integer = 0 To columnCount - 1
DataGridView1.Columns.Add(myReader.GetName(i).ToString(), myReader.GetName(i).ToString())
Next
While myReader.Read()
For i As Integer = 0 To columnCount - 1
rowData(i) = myReader.GetInt32(i).ToString()
Next
DataGridView1.Rows.Add(rowData)
End While
'thanks
'Please mark as answere if you like my answere
Sushta GuthnarPosted Mar 22, 2010, 4:27 PM
rs.MoveFirst
rs.MoveLast
i = rs.count
hlin 50 color=3
vlin 30 color=0
Tuck HohPosted Mar 22, 2010, 9:56 AM
with this OlDbdataReader = mySelCommand.ExecuteReader()
How can I fill in the DataGridView ?
Hirendra SisodiyaPosted Mar 22, 2010, 2:34 AM
you can try this:
myReader = mySelCommand.ExecuteReader()
Dim Count as integer=0
While myReader .Read
Count =Count +1
End While
i think there are no default property for counting records in datareader.
thanks
please mark as answere if you like my answere