• ODP.Net 应用 TransactionScope 数据提供程序内部错误(3000)


    1.机器启动 OracleMTSRecoveryService

     2.确保 MSDTC 服务正确配置

    3.如果没有分布式事务,连接字符串添加 PROMOTABLE TRANSACTION=LOCAL

    但是我发现,上述方式依然不能解决我的问题.

    我的数据库连接字符串格和他的是一样的:

    Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.2)(PORT = 1522)))(CONNECT_DATA =(SERVICE_NAME = ora10)));User Id=ipms;Password=ipms;

    我在本地建立了服务名后, 把数据库连接字符串改为:

    Data Source=ipms;User Id=ipms;Password=ipms;

    分布式事务就好了.

    老外原文:(鬼知道什么时候没了链接)

    Using TransactionScope with ODP.NET

    If you are using Oracle Database Provider for .NET (ODP.NET) and you want to use TransactionScope'd transactions, you may have gotten the dreaded "Data provider internal error(-3000) [System.String]" exception. I'll explain how I fixed it.

    First, if you want to support distributed transactions, make sure you have the OracleMTSRecoveryService service installed and running on your machine (it comes with the Oracle Data Access Components installation), or any other machine on your network, as long as properly configured on the MSDTC tab on the Component Services applet.

    If you don't need distributed transactions, you can place the connection string setting PROMOTABLE TRANSACTION=LOCAL on your connection string, for example:

    DATA SOURCE=(DESCRIPTION=(ADDRESS=(COMMUNITY=TCP.Some.Community)(PROTOCOL=TCP)(HOST=Some.Host)(PORT=1522))(CONNECT_DATA=(SID=SomeSid)));USER ID=SomeUsername;PASSWORD=SomePassword;PROMOTABLE TRANSACTION=LOCAL

    Now you can have:

    using (TransactionScope tx = new TransactionScope())

    {

        using (OracleConnection con = new OracleConnection(@"DATA SOURCE=(DESCRIPTION=(ADDRESS=(COMMUNITY=TCP.Some.Community)(PROTOCOL=TCP)(HOST=Some.Host)(PORT=1522))(CONNECT_DATA=(SID=SomeSid)));USER ID=SomeUsername;PASSWORD=SomePassword;PROMOTABLE TRANSACTION=LOCAL"))

        using (OracleCommand cmd = con.CreateCommand())

        {

            con.Open();  //no longer crashes here

            cmd.CommandText =
    "SELECT sysdate FROM dual";        DateTime date = (DateTime)cmd.ExecuteScalar();

        }

    }

    If you need more information, check the Oracle Data Provider for .NET Developer's Guide, it's the e10927.pdf file on the B28359_01\win.111 folder of the Oracle documentation (version 11g).

    alarm   作者:NewSea     出处:http://newsea.cnblogs.com/    QQ,MSN:iamnewsea@hotmail.com

      如无特别标记说明,均为NewSea原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。
  • 相关阅读:
    selector
    c# word 转pdf 导出失败,因为此功能尚未安装
    Jquery
    Enter
    获取当前地址的参数值
    无法向会话状态服务器发出会话状态请求。
    Ajax 跨域请求
    JsonResult 处理时间格式
    VS2013打开项目提示"Asp.net4.5未在web服务器上注册
    死锁
  • 原文地址:https://www.cnblogs.com/newsea/p/1901194.html
Copyright © 2020-2023  润新知