Solved

COMMIT TRANS WITH ADO

Posted on 1998-10-14
4
504 Views
Last Modified: 2013-12-25
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.
0
Comment
Question by:mxclouti
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
vmano earned 90 total points
Comment Utility
try this:
move the line conADO.BeginTrans before you open the recordset.
and move the line conADO.CommitTrans  before you close the recordset.your code should look someting like this:

conADO.BeginTrans
Set rstADO = .....

for nInd = 1 to 10
  rstADO.addnew
  ...
  rstADO.update
next

rstADO.Close
conADO.CommitTrans  

let me know if this helps
vmao



0
 
LVL 3

Expert Comment

by:vmano
Comment Utility
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
0
 

Author Comment

by:mxclouti
Comment Utility
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.
0
 
LVL 3

Expert Comment

by:vmano
Comment Utility
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



0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now