Solved

Error when I try to commit my transaction

Posted on 2001-06-12
6
234 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA error replacing data 6 40
Can we place a tooltip on the actual vb6 form 5 48
VB6 ListBox Question 4 48
transition to visual .net from vb6 5 37
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

840 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