Solved

Error when I try to commit my transaction

Posted on 2001-06-12
6
232 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Macro: print each sheet to pdf using ExportAsFixedFormat 11 48
Microsoft Access combo box help 2 47
Copy a row 12 62
Passing a Text Box name to a Sub 6 96
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…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

777 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