Is Visual Basic recordcount property of recordset giving problems

I do not receive a count on rs.recordcount..it reurns a zero

[67 byte] By [VibhavariGovindPanse] at [2008-2-4]
# 1
is this vb6? If so, in ADO, you need to read the recordset in first in order to view the recordcount:


Dim lCount as Long
If Not (rs.EOF and rs.BOF) Then
rs.MoveLast
rs.MoveFirst
lCount = rs.RecordCount
End If

-Mike

chid at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Also, set the recordset's CursorLocation property to adUseClient...

cheers,
Paul June A. Domag

PaulDomag at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
Vibhavari Govind Panse wrote:

I do not receive a count on rs.recordcount..it reurns a zero


Vibhavari,

While both of the posts are correct, there are certain situations where each would apply.

If the location of the cursor is client side, and the cursor is static, then you will get a value for the recordcount.

Also, for any other cursor, regardless of location or type, once you cycle to the end of the cursor, you will have the recordcount available to you.

Hope this helps.

- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

casperOne at 2007-8-21 > top of Msdn Tech,Visual Basic,Visual Basic General...