Correct, it will only tell you if there is one ir more rows in the
DataReader. It is generally used before trying to use the Read method to
check if there are any rows. I suppose that you could do a ExecuteScalar to
get the count along these lines:
Dim rowCount As Integer
Dim rowCountSQL As String = "SELECT COUNT(*) FROM tablename"
Dim yourConnection As New SqlConnection("...")
Dim yourCommand As New SqlCommand(rowCountSQL)
rowCount = CInt(yourCommand.ExecuteScalar())
--
Carsten Thomsen
Communities -
http://community.integratedsolutions.dk
"David Thielen" <(E-Mail Removed)> wrote in message
news:2DC0EE25-DC8E-4FC5-B331-(E-Mail Removed)...
> The way I read the docs for HasRows is it tells you if you have any from
> the
> select, but not if you have any more? Are you sure this works for all
> DbConnection drivers?
>
> --
> thanks - dave
>
>
> "CT" wrote:
>
>> You can use the HasRows proeprty to check if there are any more rows. It
>> might not be what you want, but you can do this without movinf the
>> cursor,
>> which is what the Read method does.
>>
>> --
>> Carsten Thomsen
>> Communities - http://community.integratedsolutions.dk
>>
>> "David Thielen" <(E-Mail Removed)> wrote in message
>> news:5639901C-363D-436D-807E-(E-Mail Removed)...
>> > Hi;
>> >
>> > That's what I figured but it never hurts to ask. I can't do a count
>> > because
>> > I don't control the select.
>> >
>> > Oh well, just makes my coding a little harder.
>> >
>> > --
>> > thanks - dave
>> >
>> >
>> > "Kevin Yu [MSFT]" wrote:
>> >
>> >> Hi dave
>> >>
>> >> As far as I know, we cannot get the row count for a DataReader.
>> >> Because
>> >> when you open the data reader, a cursor is open the on the server, it
>> >> doesn't provide the row count information. You can try to use COUNT in
>> >> the
>> >> SQL statement to get the row count first.
>> >>
>> >> Kevin Yu
>> >> =======
>> >> "This posting is provided "AS IS" with no warranties, and confers no
>> >> rights."
>> >>
>> >>
>>
>>
>>