Solved

Error when I try to commit my transaction

Posted on 2001-06-12
6
231 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
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 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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now