Oracle.ManagedDataAccess.dll中发生类型为“ OracleInternal.NotificationServices.ONSException”的第一次机会异常

时间:2018-07-21 09:16:32

标签: c# oracle visual-studio-2013 database-connection oracle12c

我的项目无法正常运行我的应用代码

string oradb = "DATA SOURCE=192.168.1.27:1521/TEST;DBA PRIVILEGE=SYSDBA;PERSIST SECURITY INFO=True;USER ID=SYS;PASSWORD=1234";
            OracleConnection conn = new OracleConnection(oradb); // C#
            conn.Open();
            OracleCommand cmd = new OracleCommand();
            cmd.Connection = conn;
            cmd.CommandText = "INSERT INTO URUNLER VALUES('" + textBox1.Text.ToString() + "','" + textBox2.Text.Count() + "', '" + textBox3.Text + "','" + textBox4.Text + "')";
            OracleDataAdapter adapter = new OracleDataAdapter();
            adapter.InsertCommand = cmd;
            conn.Dispose();

我的 app.config 代码

<connectionStrings>
<add name="OracleDbContext" connectionString="User Id=SYS;Password=1234;Data Source=192.168.1.27:1521/TEST"
  providerName="Oracle.ManagedDataAccess.Client" />
<add name="WindowsFormsApplication17.Properties.Settings.ConnectionString"
  connectionString="DATA SOURCE=192.168.1.27:1521/TEST;DBA PRIVILEGE=SYSDBA;PASSWORD=1234;PERSIST SECURITY INFO=True;USER ID=SYS"
  providerName="Oracle.ManagedDataAccess.Client" />

<dataSources>
    <dataSource alias="TEST" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.27)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=TEST))) "/>
  </dataSources>

我的 tnsnames.ora 文件是;

LISTENER_TEST =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.27)(PORT = 1521))


ORACLR_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
    (CONNECT_DATA =
      (SID = CLRExtProc)
      (PRESENTATION = RO)
    )
  )

TEST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.27)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )

感谢您的帮助

0 个答案:

没有答案