
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.