Solved

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

Posted on 2002-07-30
6
1,812 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
[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
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Independent Software Vendors: 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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

733 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