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
 
Back
Top