PDA

Click to See Complete Forum and Search --> : Getting the RecordCount


Zeee
Jun 2nd, 2000, 12:33 AM
How can I get the record count value in an ADODB.Recordset object? It always returns a -1. Thanks.

Serge
Jun 2nd, 2000, 12:46 AM
You have to change the CursorLocation property to adUseClient before you open your recordset.

Dr_Evil
Jun 2nd, 2000, 12:48 AM
Have you tried using anything similar to this?


Dim cnn As Connection
Dim rs As Recordset
Dim rc As String


.....
.......

Set rs = New Recordset
rs.Open
rc = rs.RecordCount
Label1.Caption = rc
rs.Close

JasonGS
Jun 2nd, 2000, 12:49 AM
I've noticed that setting the ADO Recordset cursor to Static will return a record count (which makes sense, if the recordset changes, how can you count it?)

adoRset.Open "table", adoConn, adOpenStatic, adLockReadOnly

Mongo
Jun 2nd, 2000, 01:33 AM
Use either adOpenKeyset or adOpenStatic as the CursorType for server side cursors, or use a client side cursor (since client side cursors use only adOpenStatic for CursorTypes).

Zeee
Jun 2nd, 2000, 02:03 AM
I'm opening the recordset with this statement:

Rst.Open "SELECT * FROM <TABLE>", Conn, adOpenDynamic, adLockOptimistic, adCmdText

Have tried Serge's tip and it worked! Thanks Serge and to the others who gave their tips....