how many rows in Datareader

  • Thread starter Thread starter Daniel Sélen Secches
  • Start date Start date
D

Daniel Sélen Secches

how can I know how many rows i have in a Data reader?

is that possible?

because i wanna do a progress bar of the job because it could take a several
minutes
the way I thought is like that but is a slow way
dim i as integer = 0
while dr.read()
i += 1
end while

--
tks.

Daniel Sélen Secches
CWD Web Internet.
www.cwd.com.br
 
As far as I know you won't know how many records a DataReader has since it
is a serverside forward only cursor.

Regards,

--

Nico Debeuckelaere (MVP VB.NET)

ND-Sign BVBA (Microsoft Certified Partner since 2004)
Pierstraat 135
B-2840 Rumst
URL: http://www.nd-sign.com
== ND-Sign, Designed for you ==
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
From the existing reader, no way to know.

AFAIK, your only option would be to do an ExecuteScalar with select count(*)
from (tableset) where (criteria) then open your reader.
 
Hi Daniel
\\\
Dim Conn As New SqlConnection(connString)
Dim cmd As SqlCommand
cmd = New SqlCommand("select count(*) from tbl", Conn)
cmd.Connection.Open()
Dim count As Integer = CInt(cmd.ExecuteScalar())
Conn.Close()
///
I hope this helps?

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

Similar Threads

what is wrong? 10
I and the listview again 2
on closing event of the form 3
listView - filling it with datareader 3
Excel Add rows automatically in excel 3
DataReader with Datatable Vs Dataset 4
SQL Datareader problem 3
DataReader 6

Back
Top