Transaction Problem -
04-16-2005
, 01:04 AM
I need help.
Errors:
1) System.Data.SqlClient.SqlException: Distributed transaction completed.
Either enlist this session in a new transaction or the NULL transaction.
2) System.Runtime.InteropServices.COMException (0x8004D00E): Exception from
HRESULT: 0x8004D00E.
------------------------------------------------------------------------
Code Attached
=============
Try
objSqlCon.Open()
objTransaction = objSqlCon.BeginTransaction
objCom.Transaction = objTransaction
'Inserts a Campaign in a table and returns the identity.
'=======================================
objCom.CommandType = CommandType.StoredProcedure
objCom.CommandText = "MDTS_INSERT_CAMPAIGN"
dr = objCom.ExecuteReader()
If (dr.Read()) Then
decInserted_Camp_ID = dr.GetDecimal(0)
emailId = "admin" & decInserted_Camp_ID.ToString
End If
dr.Close()
If (Not strURL.Trim = "") Then
'Inserts come more data in another table.
'=============================
objCom.CommandType = CommandType.StoredProcedure
objCom.CommandText = "MDTS_INSERT_CAMPAIGN_URL"
objCom.ExecuteNonQuery()
End If
'Storing file attachment content as an array of byte
'================================================= ==
If (strAttachFileName.Equals("") = False) Then
Try
'Inserts Some attachment/binary data in another table
'======================================
objCom.CommandText = "MDTS_INSERT_ITEM"
objCom.CommandType = CommandType.StoredProcedure
objCom.ExecuteNonQuery()
Catch Exc As Exception
'Error Logging
'==========
Dim objLog As New MdtsErrorLog()
objLog.LogError("FrontDesk", "clsViewCampaignOrder" & vbNewLine &
"decInsertCampaignOrder() Exception [Inner]: " & vbNewLine & Exc.ToString)
objLog = Nothing
End Try
End If
'==================================
objJmail.Domain = DomainName
objJmail.bl_createPOP(emailId)
'Logging pop mail creation
'==================
'ADDED FOR CREATING THE MAIL ACCOUNT
'Adding new list of Recipients for the current campaign
'======================================
doc.LoadXml(strXML4Recipients)
node = doc.DocumentElement
nodelist = node.SelectNodes("/MDTS/MdtsCampaign/Recipients/Recipient")
'Inserts Mail Recipients Data in another table in loop
'=====================================
For intCounter = 0 To nodelist.Count - 1
If (IsNothing(nodelist(intCounter).Attributes("To")) = False) Then
strEMailID = nodelist(intCounter).Attributes("To").Value
strTempXML4Recipient = "<MDTS><MdtsCampaign><Recipients>"
strTempXML4Recipient = strTempXML4Recipient & nodelist(intCounter)
..OuterXml
strTempXML4Recipient = strTempXML4Recipient &
"</Recipients></MdtsCampaign></MDTS>"
objCom.CommandType = CommandType.StoredProcedure
objCom.CommandText = "MDTS_INSERT_RECIPIENTS"
objCom.ExecuteNonQuery()
End If
Next
'Finally Commits
'===========
objTransaction.Commit()
Return decInserted_Camp_ID
Catch Exc As Exception
'InCase of Error, calls for a Rollback
'=========================
objTransaction.Rollback()
'Error Logging
'==========
Dim objLog As New MdtsErrorLog()
objLog.LogError("FrontDesk", "clsViewCampaignOrder" & vbNewLine &
"decInsertCampaignOrder() Exception [Outer]: " & vbNewLine & Exc.ToString)
objLog = Nothing
Return 0
Finally
objTransaction.Dispose()
dr.Close()
objCom.Dispose()
objSqlCon.Close()
objSqlCon.Dispose()
dr = Nothing
objJmail = Nothing
objTransaction = Nothing
node = Nothing
nodelist = Nothing
doc = Nothing
objCom = Nothing
objSqlCon = Nothing
End Try |