datareader -how can I know "no of records" return ?

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

I can't find any property about the "no of records" of datareader .
I don't want to loop the datareader and use counter to count it.
Any suggestion?
Thanks
 
Hi Agnes,

You can try this,
\\\\
Dim cmd As SqlCommand
Dim sqlstring As String = "select count(*) from tbl"
cmd = New SqlCommand(sqlstring, conn)
cmd.Connection.Open()
Dim count As Integer = CInt(cmd.ExecuteScalar())
conn.Close()
////
I hope this helps a little bit?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top