.recordcount returns -1

bsams
05-14-2003, 09:05 AM
I'm having a hard time getting .recordcount and .absoluteposition to give me anything other than -1. I have a status bar and want one of the cells to show 'Record x of x' when I navigate my recordset. Here's the code I have (the msgbox is just for debugging purposes):

Dim myConnection As ADODB.Connection
Dim myRecordset As ADODB.Recordset

Set myConnection = New ADODB.Connection
Set myRecordset = New ADODB.Recordset

myConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & dbPath
myRecordset.Open "SELECT * FROM Customers", myConnection, adOpenDynamic, adLockOptimistic, adCmdText

myRecordset.MoveLast
msgbox myRecordset.recordcount

Akim
05-14-2003, 09:09 AM
http://www.visualbasicforum.com/t78250.html

SpaceFrog
05-14-2003, 09:12 AM
try a recordset.movefirst before calling the recordcount ...

bsams
05-14-2003, 09:30 AM
try a recordset.movefirst before calling the recordcount ...

I've tried that. It didn't work.

NoahBody
05-14-2003, 09:31 AM
Please read my comments in the thread:

"Recordcount in SQL Server "

->N.

bsams
05-14-2003, 09:38 AM
Please read my comments in the thread:

"Recordcount in SQL Server "

->N.

I tried looking that up yersteday. The "Recordcount in SQL Server" post I find doesn't have a post by you. Is this the one: http://www.visualbasicforum.com/t78482.html

lebb
05-14-2003, 02:21 PM
Serverside cursors and many cursor types will not return valid rowcounts. The recordset must be bookmarkable (test the .Bookmarkable property to see) in order to support it. Try a client-side cursor with adOpenStatic.

BTW, I believe this (http://www.visualbasicforum.com/showthread.php?postid=380265#post380265) is the post Noah was referring to.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum