Solved

Error when I try to commit my transaction

Posted on 2001-06-12
6
238 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
[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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

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

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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