Problem writing to Access 97 DB with ADO 1.5 and 2.1 (using ODBC) 
Author Message
 Problem writing to Access 97 DB with ADO 1.5 and 2.1 (using ODBC)

Hi,

Visual Basic 5.0 Enterprise SP3
ADO 1.5
ADO 2.1

I'm moving some existing middle tier code from RDO to ADO. This has become a
necessity because my current code doesn't seem to work once MDAC 2.1 is
installed, and since it gets installed with virtually everything now (the
newer stuff at least), this will wreak havoc with my current installations!

Currently, I use an ODBC DSN to locate and connect to my DB (Access or SQL
Server). The RDO works as it should, but I'm having a hell of a time getting
UPDATEs and INSERTs to work (SELECTs are not a problem). By the way, I'm
using stored procs.

I keep getting the same error.. "The operation requested by the application
is not supported by the provider."

This is the code I'm using to CONNECT. You'll notice I tried a direct
connection to the DB as well as the ODBC DSN method...

====================================

AccessConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
                   "DBQ=idCoreDB.mdb;" & _
                   "DefaultDir=C:\Data\idDev\DB\Core\;" & _
                   "SystemDB=c:\Data\idDev\DB\Core\IDRIVE.MDW;" & _
                   "UID=idUser;" & _
                   "PWD=idTest;"

        ' open the connection
        Set moConnection = New ADODB.Connection
        With moConnection
            '.Mode = adModeReadWrite

            .ConnectionString =
"DSN=InnerDriveDB;UID=idUser;PWD=idTest;Mode=ReadWrite"
            '.ConnectionString = AccessConnect
            Call .Open
        End With

==========================

Here's the UPDATE and INSERT code. I'm using stored procs that have been
thoroughly tested.
==========================

            ' Set the parameters info
            ReDim vParams(0)
            vParams(0) = ModelId

            With oCommand
                Set .ActiveConnection = GetActiveConnection
                .CommandText = "{Call sp_ModelsById (?)}"
                .CommandType = adCmdUnknown

                Set oRecordSet = .Execute(lRecordsAffected, vParams(),
adCmdUnknown)
            End With

           'Set oRecordSet = New ADODB.Recordset
           ' Call oRecordSet.Open(oCommand, , adOpenDynamic)

            With oRecordSet
                If Not .EOF Then

                        !NameE = NameE            ' ERROR OCCURS HERE
                        !ModifiedBy = "test"
                        !ModifiedDate = Format(Now, "mm/dd/yyyy")
                    Call .Update
                End If
                Call .Close
            End With

==========================

I think the problem may be with my connection string. The Command.Execute
returns the correct record, but an error occurs when I try to assign a new
value to the RecordSet!NameE field. Setting the Mode property of the
Connection doesn't seem to work either. The commented code represents my
other attempts at resolving this problem. I've tried this on separate
machines, one with ADO 1.5 and one with ADO 2.1. I get the same error every
time.

Got any ideas? Any help you can give will be much appreciated.

Thanks in advance.

Edward R. Correa
InnerDrive Systems Inc.



Fri, 15 Mar 2002 03:00:00 GMT  
 Problem writing to Access 97 DB with ADO 1.5 and 2.1 (using ODBC)
I think I know the cause of your error -

By default, when you open a recordset, the LockType and CursorType
properties are set to adUnspecified. This means that you are not able
to do anything to the recordset, leading to the error you got.

To solve this problem add the following code to your code

With oRecordset
    .LockType = adLockOptimistic (or Whatever)
    .CursorType = adOpenStatic (or whatever)
    .CursorLocation = adUseServer
End With

Stuart



Quote:
> Hi,

> Visual Basic 5.0 Enterprise SP3
> ADO 1.5
> ADO 2.1

> I'm moving some existing middle tier code from RDO to ADO. This has
become a
> necessity because my current code doesn't seem to work once MDAC 2.1
is
> installed, and since it gets installed with virtually everything now
(the
> newer stuff at least), this will wreak havoc with my current
installations!

> Currently, I use an ODBC DSN to locate and connect to my DB (Access
or SQL
> Server). The RDO works as it should, but I'm having a hell of a time
getting
> UPDATEs and INSERTs to work (SELECTs are not a problem). By the way,
I'm
> using stored procs.

> I keep getting the same error.. "The operation requested by the
application
> is not supported by the provider."

> This is the code I'm using to CONNECT. You'll notice I tried a direct
> connection to the DB as well as the ODBC DSN method...

> ====================================

> AccessConnect = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
>                    "DBQ=idCoreDB.mdb;" & _
>                    "DefaultDir=C:\Data\idDev\DB\Core\;" & _
>                    "SystemDB=c:\Data\idDev\DB\Core\IDRIVE.MDW;" & _
>                    "UID=idUser;" & _
>                    "PWD=idTest;"

>         ' open the connection
>         Set moConnection = New ADODB.Connection
>         With moConnection
>             '.Mode = adModeReadWrite

>             .ConnectionString =
> "DSN=InnerDriveDB;UID=idUser;PWD=idTest;Mode=ReadWrite"
>             '.ConnectionString = AccessConnect
>             Call .Open
>         End With

> ==========================

> Here's the UPDATE and INSERT code. I'm using stored procs that have
been
> thoroughly tested.
> ==========================

>             ' Set the parameters info
>             ReDim vParams(0)
>             vParams(0) = ModelId

>             With oCommand
>                 Set .ActiveConnection = GetActiveConnection
>                 .CommandText = "{Call sp_ModelsById (?)}"
>                 .CommandType = adCmdUnknown

>                 Set oRecordSet = .Execute(lRecordsAffected, vParams(),
> adCmdUnknown)
>             End With

>            'Set oRecordSet = New ADODB.Recordset
>            ' Call oRecordSet.Open(oCommand, , adOpenDynamic)

>             With oRecordSet
>                 If Not .EOF Then

>                         !NameE = NameE            ' ERROR OCCURS HERE
>                         !ModifiedBy = "test"
>                         !ModifiedDate = Format(Now, "mm/dd/yyyy")
>                     Call .Update
>                 End If
>                 Call .Close
>             End With

> ==========================

> I think the problem may be with my connection string. The
Command.Execute
> returns the correct record, but an error occurs when I try to assign
a new
> value to the RecordSet!NameE field. Setting the Mode property of the
> Connection doesn't seem to work either. The commented code represents
my
> other attempts at resolving this problem. I've tried this on separate
> machines, one with ADO 1.5 and one with ADO 2.1. I get the same error
every
> time.

> Got any ideas? Any help you can give will be much appreciated.

> Thanks in advance.

> Edward R. Correa
> InnerDrive Systems Inc.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sat, 16 Mar 2002 03:00:00 GMT  
 Problem writing to Access 97 DB with ADO 1.5 and 2.1 (using ODBC)
Thanks for your help Stuart. The suggestion you made worked pretty well, but
now I get the following error when I call the Update method....

[Microsoft][ODBC Driver Manager] Descriptor type out of range

Quote:
>>             With oRecordSet
>>                 If Not .EOF Then

>>                         !NameE = NameE
>>                         !ModifiedBy = "test"
>>                         !ModifiedDate = Format(Now, "mm/dd/yyyy")
>>                     Call .Update
' ERROR OCCURS HERE
>>                 End If
>>                 Call .Close
>>             End With

Any ideas? I've been checking the Knowledge Base, but that is going to take
some time!!

Thanks in advance.

Ed

Quote:

>I think I know the cause of your error -

>By default, when you open a recordset, the LockType and CursorType
>properties are set to adUnspecified. This means that you are not able
>to do anything to the recordset, leading to the error you got.

>To solve this problem add the following code to your code

>With oRecordset
>    .LockType = adLockOptimistic (or Whatever)
>    .CursorType = adOpenStatic (or whatever)
>    .CursorLocation = adUseServer
>End With

>Stuart



Sat, 16 Mar 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ADO 2.1 Access 97 and AutoNumber

2. ODBC ver. 3.7 and ADO 1.5 problem

3. VB5EE setup wizard and mdac 1.5 (ado 1.5) problem

4. Upgrading / Downgrading between AD0 1.5/2.1

5. Problem with ADO 1.5 and Access 8.0

6. Connecting to Access 97 Database using ADO with OLE DB Driver

7. Connecting to Access 97 Database using ADO with OLE DB Driver

8. ADO Update (using VB) of Memo fields in Access 97 DB

9. Performance issue - Access 2000 using VB6 and ADO 2.1 with SQL

10. Add fields to an Access 2000 Table on the fly using ADO 2.1

11. MDAC 2.1 and Access 97(-) Incompatable

12. Access 97 vs 2000 + MDAC 2.1 SP2 vs 2.5

 

 
Powered by phpBB® Forum Software