RecordCount using ADO (Access2000) 
Author Message
 RecordCount using ADO (Access2000)

Hi,

How can one get the RecordCount value using ADO?  (I already have code built
using DAO, but I want to remove the [Microsoft DAO 3.6 Object Library]
reference from my database.)

I have read the Microsoft article (PRB: ADO: Recordcount May Return -1)
found at:
http://www.*-*-*.com/ ;en-us;Q194973  and I
followed the instructions in "Steps to reproduce Behavior" # 5 and #6, but
could not get the code from the example to work.  I get a error:
Run-time error '-2147467259 (80004005)'
Unrecognized database format 'd:\data\Test.mdb'

Can anyone help?
this is what I have so far...

Public Function ADO_SUB()

Dim myDB As Database
Dim myRS As Recordset

    Set myRS = New ADODB.Recordset
    myRS.CursorLocation = adUseServer
    myRS.Open "Select qRecordCount from qCompareCount",
"Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Data Source=d:\Data\Test.mdb", adOpenForwardOnly, adLockUnspecified
    MsgBox myRS

End Function

my current DAO code works; it is:

On Error GoTo Err_Archive
Dim myDB As DAO.Database
Dim myRS As DAO.Recordset
    Set myDB = CurrentDb()
    Set myRS = myDB.OpenRecordset("qCompare", dbOpenDynaset)
    myRS.MoveLast
    MsgBox myRS.RecordCount
    Exit Sub

Err_Archive:
    If Err.number = 3021 Then
        MsgBox " There are no records to archive!      " _
                , vbCritical, " No Records Available!  "
        Exit Sub
    End If

thanks in advance!
-jim



Tue, 01 Mar 2005 02:21:59 GMT  
 RecordCount using ADO (Access2000)
msgbox myRs.RecordCount

--

------------------------------------
Make Unlimited phone calls from your PC to ANY phone in the World!
http://www.eboom.com/free/

Quote:
> Hi,

> How can one get the RecordCount value using ADO?  (I already have code
built
> using DAO, but I want to remove the [Microsoft DAO 3.6 Object Library]
> reference from my database.)

> I have read the Microsoft article (PRB: ADO: Recordcount May Return -1)
> found at:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;Q194973  and I
> followed the instructions in "Steps to reproduce Behavior" # 5 and #6, but
> could not get the code from the example to work.  I get a error:
> Run-time error '-2147467259 (80004005)'
> Unrecognized database format 'd:\data\Test.mdb'

> Can anyone help?
> this is what I have so far...

> Public Function ADO_SUB()

> Dim myDB As Database
> Dim myRS As Recordset

>     Set myRS = New ADODB.Recordset
>     myRS.CursorLocation = adUseServer
>     myRS.Open "Select qRecordCount from qCompareCount",
> "Provider=Microsoft.Jet.OLEDB.3.51;" & _
> "Data Source=d:\Data\Test.mdb", adOpenForwardOnly, adLockUnspecified
>     MsgBox myRS

> End Function

> my current DAO code works; it is:

> On Error GoTo Err_Archive
> Dim myDB As DAO.Database
> Dim myRS As DAO.Recordset
>     Set myDB = CurrentDb()
>     Set myRS = myDB.OpenRecordset("qCompare", dbOpenDynaset)
>     myRS.MoveLast
>     MsgBox myRS.RecordCount
>     Exit Sub

> Err_Archive:
>     If Err.number = 3021 Then
>         MsgBox " There are no records to archive!      " _
>                 , vbCritical, " No Records Available!  "
>         Exit Sub
>     End If

> thanks in advance!
> -jim



Tue, 01 Mar 2005 03:50:54 GMT  
 RecordCount using ADO (Access2000)
i revising the code to:
    rs.CursorLocation = adUseClient
    rs.Open "Select qRecordCount from qCompareCount",
"Provider=Microsoft.Jet.OLEDB.3.51;" & _
        "Data Source=d:\Data\Test.mdb", adOpenStatic, adLockUnspecified
-and-
    rs.CursorLocation = adOpenStatic
    rs.Open "Select qRecordCount from qCompareCount",
"Provider=Microsoft.Jet.OLEDB.3.51;" & _
        "Data Source=d:\Data\Test.mdb", adOpenForwardOnly, adLockUnspecified

neither worked... i still got the error:
    Run-time error '-2147467259 (80004005)'
    Unrecognized database format 'd:\data\Test.mdb'


Quote:
> Try changing the cursor to adOpenStatic. I fumble around
> with ADO until I hit it right.
> >-----Original Message-----
> >Hi,

> >How can one get the RecordCount value using ADO?  (I
> already have code built using DAO, but I want to remove
> the [Microsoft DAO 3.6 Object Library] reference from my
> database.)

> >I have read the Microsoft article (PRB: ADO: Recordcount
> May Return -1) found at:
> >http://support.microsoft.com/default.aspx?scid=kb;en-
> us;Q194973  and I followed the instructions in "Steps to
> reproduce Behavior" # 5 and #6, but could not get the code
> from the example to work.  I get a error:
> >Run-time error '-2147467259 (80004005)'
> >Unrecognized database format 'd:\data\Test.mdb'

> >Can anyone help?
> >this is what I have so far...

> >Public Function ADO_SUB()

> >Dim myDB As Database
> >Dim myRS As Recordset

> >    Set myRS = New ADODB.Recordset
> >    myRS.CursorLocation = adUseServer
> >    myRS.Open "Select qRecordCount from
> qCompareCount", "Provider=Microsoft.Jet.OLEDB.3.51;" & _
> >"Data Source=d:\Data\Test.mdb", adOpenForwardOnly,
> adLockUnspecified
> >    MsgBox myRS

> >End Function

> >my current DAO code works; it is:

> >On Error GoTo Err_Archive
> >Dim myDB As DAO.Database
> >Dim myRS As DAO.Recordset
> >    Set myDB = CurrentDb()
> >    Set myRS = myDB.OpenRecordset("qCompare",
> dbOpenDynaset)
> >    myRS.MoveLast
> >    MsgBox myRS.RecordCount
> >    Exit Sub

> >Err_Archive:
> >    If Err.number = 3021 Then
> >        MsgBox " There are no records to archive!      " _
> >                , vbCritical, " No Records Available!  "
> >        Exit Sub
> >    End If



Tue, 01 Mar 2005 04:00:34 GMT  
 RecordCount using ADO (Access2000)
sorry, the code breaks before i even get to the msgbox.  it breaks on the
line:

     myRS.Open "Select qRecordCount from qCompareCount",
 "Provider=Microsoft.Jet.OLEDB.3.51;" & _
 "Data Source=d:\Data\Test.mdb", adOpenForwardOnly, adLockUnspecified


Quote:

> msgbox myRs.RecordCount

> http://www.eboom.com/free/


> > Hi,
> > How can one get the RecordCount value using ADO?  (I already have code
> built
> > using DAO, but I want to remove the [Microsoft DAO 3.6 Object Library]
> > reference from my database.)
> > I have read the Microsoft article (PRB: ADO: Recordcount May Return -1)
> > found at:
> > http://support.microsoft.com/default.aspx?scid=kb;en-us;Q194973  and I
> > followed the instructions in "Steps to reproduce Behavior" # 5 and #6,
but
> > could not get the code from the example to work.  I get a error:
> > Run-time error '-2147467259 (80004005)'
> > Unrecognized database format 'd:\data\Test.mdb'

> > Can anyone help?
> > this is what I have so far...

> > Public Function ADO_SUB()

> > Dim myDB As Database
> > Dim myRS As Recordset

> >     Set myRS = New ADODB.Recordset
> >     myRS.CursorLocation = adUseServer
> >     myRS.Open "Select qRecordCount from qCompareCount",
> > "Provider=Microsoft.Jet.OLEDB.3.51;" & _
> > "Data Source=d:\Data\Test.mdb", adOpenForwardOnly, adLockUnspecified
> >     MsgBox myRS

> > End Function

> > my current DAO code works; it is:

> > On Error GoTo Err_Archive
> > Dim myDB As DAO.Database
> > Dim myRS As DAO.Recordset
> >     Set myDB = CurrentDb()
> >     Set myRS = myDB.OpenRecordset("qCompare", dbOpenDynaset)
> >     myRS.MoveLast
> >     MsgBox myRS.RecordCount
> >     Exit Sub

> > Err_Archive:
> >     If Err.number = 3021 Then
> >         MsgBox " There are no records to archive!      " _
> >                 , vbCritical, " No Records Available!  "
> >         Exit Sub
> >     End If

> > thanks in advance!
> > -jim



Tue, 01 Mar 2005 04:05:18 GMT  
 RecordCount using ADO (Access2000)


Quote:

> How can one get the RecordCount value using ADO?  (I already have code
> built using DAO, but I want to remove the [Microsoft DAO 3.6 Object
> Library] reference from my database.)

  SELECT COUNT(*) FROM qCompare;

You've got a database system: why not use it?

Tim F



Tue, 01 Mar 2005 06:07:06 GMT  
 RecordCount using ADO (Access2000)
The unrecognized database error probably means you need to
change the provider argument in the myRS.Open command to
use the correct version of jet.  The correct version
depends on what version of Access you used to create the
mdb.  Try checking the Access help files for ADO prodvider
options.

Josh

Quote:
>-----Original Message-----
>sorry, the code breaks before i even get to the msgbox.  
it breaks on the
>line:

>     myRS.Open "Select qRecordCount from qCompareCount",
> "Provider=Microsoft.Jet.OLEDB.3.51;" & _
> "Data Source=d:\Data\Test.mdb", adOpenForwardOnly,
adLockUnspecified



>> msgbox myRs.RecordCount

>> http://www.eboom.com/free/


>> > Hi,
>> > How can one get the RecordCount value using ADO?  (I
already have code
>> built
>> > using DAO, but I want to remove the [Microsoft DAO
3.6 Object Library]
>> > reference from my database.)
>> > I have read the Microsoft article (PRB: ADO:

Recordcount May Return -1)
Quote:
>> > found at:
>> > http://support.microsoft.com/default.aspx?scid=kb;en-
us;Q194973  and I
>> > followed the instructions in "Steps to reproduce

Behavior" # 5 and #6,

- Show quoted text -

Quote:
>but
>> > could not get the code from the example to work.  I
get a error:
>> > Run-time error '-2147467259 (80004005)'
>> > Unrecognized database format 'd:\data\Test.mdb'

>> > Can anyone help?
>> > this is what I have so far...

>> > Public Function ADO_SUB()

>> > Dim myDB As Database
>> > Dim myRS As Recordset

>> >     Set myRS = New ADODB.Recordset
>> >     myRS.CursorLocation = adUseServer
>> >     myRS.Open "Select qRecordCount from
qCompareCount",
>> > "Provider=Microsoft.Jet.OLEDB.3.51;" & _
>> > "Data Source=d:\Data\Test.mdb", adOpenForwardOnly,
adLockUnspecified
>> >     MsgBox myRS

>> > End Function

>> > my current DAO code works; it is:

>> > On Error GoTo Err_Archive
>> > Dim myDB As DAO.Database
>> > Dim myRS As DAO.Recordset
>> >     Set myDB = CurrentDb()
>> >     Set myRS = myDB.OpenRecordset("qCompare",
dbOpenDynaset)
>> >     myRS.MoveLast
>> >     MsgBox myRS.RecordCount
>> >     Exit Sub

>> > Err_Archive:
>> >     If Err.number = 3021 Then
>> >         MsgBox " There are no records to
archive!      " _
>> >                 , vbCritical, " No Records
Available!  "
>> >         Exit Sub
>> >     End If

>> > thanks in advance!
>> > -jim

>.



Tue, 01 Mar 2005 21:50:19 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. DAO Recordcount vs. ADO Recordcount

2. Can't returns RecordCount using ADO

3. Using RecordCount in ADO and Oracle

4. ADO RecordCount and EOF aren't right when using ORDER BY clause

5. ADO Programmers Must Read if using Access2000

6. How to store a picture from file in an access2000 database using ADO

7. VB6 to Access2000 using ADO

8. How can I get a list of tables using ADO + Access2000

9. VB update to Access2000 table using ADO ?

10. ADO RecordCount

11. Why doesn't Recordcount work with ADO ?

12. Problem with ADO RecordCount and RecordsAffected

 

 
Powered by phpBB® Forum Software