用COM+ 的自动事务,必须操作的对象支持,用access 调用dtc,会有莫名其妙的错误代码
FailedNo error information available: E_NOINTERFACE(0x80004002).
关于这个问题,微软有一片kb
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q221071&
<WebMethod(transactionOption:=EnterpriseServices.TransactionOption.RequiresNew)> _
Public Function HelloWorld() As String
Try
ContextUtil.EnableCommit()
DrawMoneyFromA(1000)
DepostMoneyToB(1000)
ContextUtil.SetComplete()
Return "OK!"
Catch ex As Exception
ContextUtil.SetAbort()
Return "Failed" + ex.Message
End Try
End Function
Public Sub DrawMoneyFromA(ByVal amount As Long)
'从 A 中提取一定的钱
Dim cnn As New OleDb.OleDbConnection(Me.OleDbConnection1.ConnectionString)
cnn.Open()
Dim cmd As New OleDb.OleDbCommand("Update bank set amount=amount - " & amount & " where bankaccount='A'", cnn)
cmd.ExecuteNonQuery()
End Sub
Public Sub DepostMoneyToB(ByVal amount As Long)
'从 B 加一定的钱
Dim cnn As New OleDb.OleDbConnection(Me.OleDbConnection1.ConnectionString)
cnn.Open()
Dim cmd As New OleDb.OleDbCommand("Update bank set amount=amount + " & amount & " where bankaccount='B'", cnn)
'Throw New Exception("ff")
cmd.ExecuteNonQuery()
End Sub
本文地址:http://com.8s8s.com/it/it44184.htm