Solved

Error when I try to commit my transaction

Posted on 2001-06-12
6
228 Views
Last Modified: 2012-05-04
I have a series of sqlqueries I wish to use all or none...problem is I keep getting this error message when I try to commit the transaction...
"Cannot create new connection because in manual or distributed transaction mode"

my connection object is declared in a module and then used throughout my code..

BTW:when I ask the conn for its mode it reports 0...

On Error GoTo rollback

  conn.BeginTrans
  conn.Execute (sqlstr_create_view1)
  conn.Execute (sqlstr_create_view2)
  Set resultset1 = conn.Execute(sqlstr_test)
  conn.Execute (sqlstr_drop_view1)
  conn.Execute (sqlstr_drop_view2)
 
  conn.CommitTrans
 
  GoTo skip_rollback
 
rollback:
  conn.RollbackTrans
  MsgBox Err.Description
skip_rollback:
  On Error Resume Next

0
Comment
Question by:mccainz2
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:nutwiss
ID: 6181823
are you running under MTS?
0
 
LVL 5

Author Comment

by:mccainz2
ID: 6181861
I was told somewhere else to make sure my mssql server had MSDTC agent set to autostart in the sqlserver properties....this was the configuration I started with. Not sure about MTS.....suggestion?
0
 
LVL 5

Author Comment

by:mccainz2
ID: 6181897
I was told somewhere else to make sure my mssql server had MSDTC agent set to autostart in the sqlserver properties....this was the configuration I started with. Not sure about MTS.....suggestion?
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Expert Comment

by:Feres
ID: 6182285
just a curiosity:
are you trying to use DDL commands (such as create) inside a transaction? is it safe?
0
 
LVL 5

Author Comment

by:mccainz2
ID: 6182761
I create two views inside the transcation.....is that a problem?????
0
 

Accepted Solution

by:
Feres earned 50 total points
ID: 6182798
I remember that once before I tried to use DDL (Data Definition Language) commands inside transactions and I got errors back.
This commands includes:
create tables, foreign keys, indexes, etc,
To be honest, I'm not sure, but I feel like creating views is considered DDL commands.
Inside transaction only DML (data manipulation language)

just in case, try something like this


On Error GoTo rollback

 conn.Execute (sqlstr_create_view1)
 conn.Execute (sqlstr_create_view2)
 
 conn.BeginTrans

 Set resultset1 = conn.Execute(sqlstr_test)

 conn.CommitTrans
 
 conn.Execute (sqlstr_drop_view1)
 conn.Execute (sqlstr_drop_view2)


-------------------------------------
another situation in your code, did you realize that if you get an error you try to execute a commit after execute a rollback? Try comment the line 'On Error Resume Next'  and see what happen ....

regards,
feres

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 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

10 Experts available now in Live!

Get 1:1 Help Now