RecordCount property always returns -1 
Author Message
 RecordCount property always returns -1

Hi,

I'm trying to open a connection to an Access2000 database. The recordset
rsCDs seems to open ok (i can access existing values from the database and
add new records) however, every time i use the RecordCount property is
returns -1, even though there exists records in the table. Here is my code
below:

    Dim cnnCD As ADODB.Connection
    Dim rsCDs As ADODB.Recordset
    Set cnnCD = New ADODB.Connection
    Set rsCDs = New ADODB.Recordset

    Dim sConnect As String

    sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
               "Data Source= C:\Documents and Settings\oem1\My
Documents\CD_Manager.mdb"
    cnnCD.Open sConnect

    rsCDs.Open "Select * From CDs Order by IDNumber", cnnCD, adOpenDynamic,
adLockOptimistic

    Msgbox rsCDs.RecordCount

How can i return the real number of records in the recordset?

Thanks,
Dave.



Tue, 07 Oct 2003 23:53:51 GMT  
 RecordCount property always returns -1
Hello David

Add
cnnCD.CursorLocation = adUseClient

and try

Sukesh

Quote:
> Hi,

> I'm trying to open a connection to an Access2000 database. The recordset
> rsCDs seems to open ok (i can access existing values from the database and
> add new records) however, every time i use the RecordCount property is
> returns -1, even though there exists records in the table. Here is my code
> below:

>     Dim cnnCD As ADODB.Connection
>     Dim rsCDs As ADODB.Recordset
>     Set cnnCD = New ADODB.Connection
>     Set rsCDs = New ADODB.Recordset

>     Dim sConnect As String

>     sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>                "Data Source= C:\Documents and Settings\oem1\My
> Documents\CD_Manager.mdb"
>     cnnCD.Open sConnect

>     rsCDs.Open "Select * From CDs Order by IDNumber", cnnCD,
adOpenDynamic,
> adLockOptimistic

>     Msgbox rsCDs.RecordCount

> How can i return the real number of records in the recordset?

> Thanks,
> Dave.



Wed, 08 Oct 2003 00:40:08 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. RecordCount always returns -1

2. .recordcount always returns -1

3. Microsoft Outlook Express 5 and Netscape, the AttachmentCount property always returns zero

4. MAPImessages msgSent Property always returns FALSE

5. CDO: Parent property always returns session object

6. Unable to return float, always returning int with ADO, IIS and SQLServer

7. Why is recordcount always -1?

8. Recordcount always 0 after deleting the last row when bound at a Datagrid

9. .RecordCount always = 1?

10. DAO Recordset returning incorrect recordcount

11. Can't returns RecordCount using ADO

12. HELP--Recordcount keeps returning -1

 

 
Powered by phpBB® Forum Software