zoukankan      html  css  js  c++  java
  • 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原创,版权私有,翻载必纠。欢迎交流,转载,但要在页面明显位置给出原文连接。谢谢。
  • 相关阅读:
    MySQL skip-character-set-client-handshake导致的一个字符集问题
    skip-character-set-client-handshake 与 character-set-client-handshake
    Innodb IO优化-配置优化
    MySQL InnoDB特性:两次写(Double Write)
    RDS MySQL InnoDB 锁等待和锁等待超时的处理
    充分利用CPU多核的处理能力 innodb_read_io_threads和innodb_write_io_threads
    MySQL InnoDB配置并发线程( innodb_thread_concurrency)
    innodb内部的并发线程
    innodb_flush_method理解
    测试快速关闭innodb的方法
  • 原文地址:https://www.cnblogs.com/newsea/p/1901194.html
Copyright © 2011-2022 走看看