Groups | Blog | Home
all groups > inetserver asp db > december 2003 >

inetserver asp db : Transaction Error


Niel
12/29/2003 9:44:18 AM
Hi,
I am working on ASP 3.0 with MS SQL 2000. We have an
online registration form where in once the information is
submitted (along with credit card info.) the information
is taken on another asp page where i have set the page
level transaction (transaction = required) on.
Once the information is verified on this page and if
everything is fine then internally another page is called
where the information is stored into the database.
Now i have put the error handling part in the second page
where information is verified in which i have made it that
when an error comes then the transaction should be rolled
back (ObjectContext.SetAbort) and then the error number
(Err.Number) and the error description(Err.Description)
is emailed at my address. I just put this error handling
part few days back and now not always but at times i do
get Email which has the error number and error description
as follows

--------------------------------------------------------

-2147217900 [Microsoft][ODBC SQL Server Driver][SQL
Server]Distributed transaction completed. Either enlist
this session in a new transaction or the NULL transaction.

--------------------------------------------------------

I tried searching for this error but couldn't find the
exact reason and solution for the same.
So if any one has and idea about this and the exact
solutino to it or some url where i can go and see the
solution then please let me know.

Mark Schupp
12/30/2003 8:24:42 AM
You might be able to get a better response if you posted your code.
If possible, strip it down to the bare minimum of code that still exhibits
your problem.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


[quoted text, click to view]

Niel
12/31/2003 9:47:21 AM
I haven't got any solution or answers from anyone. This is really urgent. If
anyone has an idea on this please let me know.
Any help would be appreciated.

Thank you


[quoted text, click to view]

Niel
1/1/2004 4:22:02 PM
1) This is what I have set on the top of the asp page

<%@ Language=VBScript transaction=required %>
On Error Resume Next

2) next I process the info. Like first get the information form previous
page like
Firstname = request.form("firstname")
Lastname = request.form("lastname")
And so on.. And once I have all that information (which also has the
customer credit card inforomation then it is taken to transaction processing
company for charging and once that is done I get a reply as 1,2 or 3
1 as in success, 2 as in decline(lack of funds) and 3 as in decline(due to
some other error).
If the reply is 1 then I redirect the user to final page where in insert the
information in database.
In rest of replies I just display the Error message to user.

3) After all this at the last on this page I have set the error handling
part which is as follows


if Err.number <> 0 then

ObjectContext.SetAbort

errorDesc = Err.Description
errorNo = Err.number

call sendErrorInEmail(errorNo,errorDesc)

end if


sub sendErrorInEmail(ENo,EDesc)

ErrorMsg = "<font color=black size=1 face=verdana><b>" & ENo &
"</b>&nbsp;&nbsp;" & EDesc & "</font>"

set errorMail = server.CreateObject("CDONTS.Newmail")

errorMail.From = "Admin@domain.com"
errorMail.To = "support@domain.com"
errorMail.Subject = "Error while Registering user for company"
errorMail.BodyFormat = 0
errorMail.MailFormat = 0
errorMail.Body = ErrorMsg

errorMail.Send

set errorMail = nothing

Response.Clear
Response.Write "<font color=darkblue size=1 face=verdana>There was an error
while processing your request.</font><br><br>"
Response.Write "<input type=button name=btnBck value='Back'
onclick=javascript:history.back()'>"
Response.End

end sub


4) And following is what the error message I get

-2147217900 [Microsoft][ODBC SQL Server Driver][SQL Server]Distributed
transaction completed. Either enlist this session in a new transaction or
the NULL transaction.



Hope this will help
Thank you


[quoted text, click to view]

Chris Hohmann
1/2/2004 12:27:26 PM
[quoted text, click to view]

To expand Bob's recommendation, I'd like to add that it is not advisable
to mix SQL Server transaction management with DTS/COM+ transaction
management. If the scope of your transactional logic is limited to SQL
Server then that's were the transaction management should occur. If the
scope goes beyond SQL Server, then use DTS/COM+ and make sure there are
no transaction calls in your stored procedure (this includes any sql
statements that would invoke triggers with transactional logic). You can
use RAISE ERROR/RETURN in your stored procedure to communicate status
back to DTS/COM+. In the rare case where your stored procedure needs to
be run in both a DTS/COM+ context and stand alone, you can use
@@TRANCOUNT to determine context and control the flow of your stored
procedure accordingly. However, I would strongly urge you to against
this approach except as a last resort. A stored procedure should either
be a discreet transaction onto itself or a "component" of a large
transaction, not both.


I realize there's a lot of "hand waving" in the above, but it's as
detailed as I could be absent the following:
1. The actual code for the stored procedure
2. OS Version
3. DTS Version
4. MDAC Version

Finally, here's a KB article on the error you are encountering which
discusses other possible causes.

http://support.microsoft.com/default.aspx?scid=kb;en-us;191168

HTH
-Chris Hohmann

Bob Barrows
1/2/2004 12:29:36 PM
[quoted text, click to view]

Sorry, I've never done transaction processing in my vbscript code: I've
always encapsulated my transactions in stored procedures. In fact, that is
my suggestion: put the entire process into a stored procedure, including the
email part (you can use the builtin SQLMail, or, if you prefer to use smtp
rather than mapi, install Gert Draper's XP_SMTP_SendMail (from
http://www.sqldev.net/xp/xpsmtp.htm). see
http://www.aspfaq.com/show.asp?id=2403)

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Chris Hohmann
1/2/2004 12:40:41 PM
[quoted text, click to view]
or a "component" of a large transaction, not both.

That should read "... of a LARGER transaction..."

Niel
1/3/2004 11:20:13 AM
Hi,
does any knows the solution for the problem that i have described.
Please let me know if any one has any idea about what should be done to
avoid this.

Thank you

[quoted text, click to view]

AddThis Social Bookmark Button