?
Solved

COMMIT TRANS WITH ADO

Posted on 1998-10-14
4
Medium Priority
?
523 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
vmano earned 360 total points
ID: 1496946
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
ID: 1496947
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
ID: 1496948
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
ID: 1496949
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month12 days, 2 hours left to enroll

752 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