Solved

Urgent: Cannot create new connection because in manual or distributed transaction mode.

Posted on 2002-07-30
6
1,685 Views
Last Modified: 2007-11-27
Urgent: 100 more Points will be added if the problems can be solved.

Error occur when execute the following ASP program:

Cannot create new connection because in manual or distributed transaction mode.


Set cn1 = Server.CreateObject("ADODB.Connection")
    cn1.open ....
cn1.BeginTrans
for i= 1 to x


empDesc=FindIdDescrption(ID,cn1)
response.write empDesc


cn1.execute "insert table1...."
cn1.execute "update table3"

next
cn1.CommitTrans

Function FindIdDescription(tmpCode,tmpcn1)
  Dim rstemp

    set rstemp = server.CreateObject("adodb.recordset")
    sqlstm ="select * from table2 "
    rstemp.open sqlstm ,tmpcn1
    If not rstemp.eof then
       FindDescription = rstemp("Desc")
    Else
       FindDescription = "N"
    End If
    rstemp.close
    set rstemp=nothing

End Function

How to solve this problem?
0
Comment
Question by:leo_wh_cheung
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7188002
Urgent:  Please maintain your open questions:
Query cannot be updated Date: 11/29/2000 01:35AM PST  
http://www.experts-exchange.com/mssql/Q_12010641.html
ASP command change to  Java Command Date: 06/06/2001 03:09AM PST  
http://www.experts-exchange.com/java/Q_20130580.html
Zip a file in Active Server Pages Date: 01/30/2001 02:01AM PST
http://www.experts-exchange.com/asp/Q_20065389.html
How can I set the page never timeout expired? Date: 11/30/2000 08:06PM PST  
http://www.experts-exchange.com/webdevsoftgen/Q_12037560.html

Thanks,
Anthony

0
 
LVL 32

Expert Comment

by:bhess1
ID: 7188697
I have a feeling that you oversimplified your ASP code here.  There is a known issue with this type of code, but only if there is an open rs with pending actions when you try to open another rs.

This error only occurs if you use the default Firehose cursor.  You can prevent it by setting something other than a read-only, forward-only cursor on the rsTemp open.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 7188873
Take a look at this article from MSDN:
PRB: SQLOLEDB Allows Only One Connection in Scope of Transaction
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q272358&

Thank you for maintaining your open questions,
Anthony
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 5

Accepted Solution

by:
CFXPERT earned 250 total points
ID: 7189165
If you have a connection already made make sure you close it and set it to nothing before trying to open a new connection.  Just a thought.  I know I've had problems in the past similiar to this one.
0
 

Author Comment

by:leo_wh_cheung
ID: 7208460
CFXPERT,

I solve this problem by the following method:

1. Define(Dim) a local variable in the function. Otherwise, other function can use this variable and error may occur.

2. Create another connection to update the recordset

3. make sure you close it and set it to nothing before trying to open a new connection.

Thanks!

Leo
0
 
LVL 5

Expert Comment

by:CFXPERT
ID: 7209319
Not a problem.  Glad you got it fixed.

:)
KWK
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

707 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

17 Experts available now in Live!

Get 1:1 Help Now