ITPub博客

首页 > Linux操作系统 > Linux操作系统 > ORA-02041 client database did not begin a transaction

ORA-02041 client database did not begin a transaction

原创 Linux操作系统 作者:Kenniu 时间:2019-10-22 08:39:02 0 删除 编辑

当我用VB.NET ,or C#,or ASP.NET 编程时,我会update a table on a remote oracle database, 下列问题总是发生;

ORA-02041 client database did not begin a transaction

我试过很多方法都没解决掉;终于我在帖子上找到解决的办法;有点象大海捞针:

我提供如下解决方法 :

Try this. It works for Oracle 8.1.7.0.0 and version 1.1 of .Net Framework. VS 2003

Dim sConnection As String
Dim sType As String
Dim oDS As New DataSet

GetDataSet = True

sConnection = "Provider=OraOLEDB.Oracle;Password=" & sDatabasePwd & ";User ID=" & sDatabaseSchema & ";Data Source=" & sDatabaseInstance & ";[B]DistribTX=0;[/B]"

Dim oConn As New OleDbConnection(sConnection)
Dim oDA As New OleDbDataAdapter(sSql, oConn)

Try
'oDA.MissingSchemaAction = MissingSchemaAction.AddWithKey
oDA.Fill(oDS, TableName)
Catch oException As Exception
sError = oException.Message
GetDataSet = False
Finally
oDA.Dispose()
oDA = Nothing
End Try

请你特别注意这条语句,特别重要呀...

[B]DistribTX=0;[/B]

这就是解决问题的关键点..

相关的技术文挡请参考下面的内容:

OraOLEDB-specific Connection String Attributes

OraOLEDB offers provider-specific Connection String attributes, which are set in the same way as the Provider and User ID are set. The provider-specific connection string attributes are:

Distributed Transactions

The DistribTX attribute specifies whether sessions are enabled to enlist in distributed transactions. Valid values are 0 (disabled) and 1 (enabled). The default is 1 which indicates that sessions are enabled for distributed transaction enlistments.

Applications using Microsoft Transaction Server must have DistribTX set to 1, the default.

More detail , pls, refe this Web


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30193/viewspace-90012/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2002-11-29

  • 博文量
    146
  • 访问量
    122574