Link to home
Start Free TrialLog in
Avatar of mxclouti
mxclouti

asked on

COMMIT TRANS WITH ADO

I'm using ADO 2.0 to connect to an ACCESS 97 database through an ODBC DSN.

I'm using the default provider: "MSDASQL"

Once connected, I used the following code:

conADO.BeginTrans
for nInd = 1 to 10
  rstADO.addnew
  ...
  rstADO.update
next
conADO.CommitTrans

I get the error "Operation invalid at this time." at conADO.begintrans.

WHY ?

Without begintrans and committrans, everything is working fine.
ASKER CERTIFIED SOLUTION
Avatar of vmano
vmano

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vmano
vmano

there is a correction in the line
"move the line conADO.CommitTrans before you close the recordset"

it should be
"move the line conADO.CommitTrans after you close the recordset"

sorry for the confusion.

vmano
Avatar of mxclouti

ASKER

Thanks. It's working. That was so simple.

Instead of the default provider (MSDASQL) I've tried to used the provider (Microsoft.JET.OLEDB.3.51):

conADO.ConnectionTimeout = glTimeOut
conADO.Provider = "Microsoft.JET.OLEDB.3.51"
conADO.Properties("user id") = "mxclouti"
conADO.Properties("password") = "nosmoke"
conADO.Properties("data source") = gsMDB
conADO.Properties("Jet OLEDB:System database") = gsMDW
conADO.Open
   
and I get the error "-2147467259 Unspecified error" at conADO.Open

If you can answer that for me or else I'll ask this question to all experts and accept your answer.

Thanks.
I am not sure of the error number. I never tried like what you did. here is an alternative to what you are doing.

Dim Con as String

Con = "Driver={....}; Dbq=...;DefaultDir=...;Uid=...;Pwd=...;"

conADO.ConnectionString = Con
conADO.Open
..
conADO.Close
conADO.ConnectionString = ""

let me know if this helps
vmano