0

运行以下功能时,我收到以下错误。catch 表示它打开连接的行 (Me.OracleConn.Open())。

我已确保服务器存在于 TNSNAMES.ora 文件中。

Imports NetOracle = System.Data.OracleClient
...
Private Property OracleConn As NetOracle.OracleConnection
...
    Private Function Connect_To_Oracle() As Boolean
        Connect_To_Oracle = False

        Try

            'Me.OracleConn = New NetOracle.OracleConnection
            Me.OracleConn = New System.Data.OracleClient.OracleConnection
            Me.OracleConn.ConnectionString = "Data Source = (DESCRIPTION=" & _
                      "(ADDRESS_LIST=(ADDRESS = (PROTOCOL = TCP)(HOST = servername.net)(PORT = ####)))" & _
                      "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME = risk)));" & _
                      "User Id=user_name;Password=password;"

            Me.OracleConn.Open()
            Connect_To_Oracle = True
        Catch ex As Exception
            MsgBox("Oracle Connection Error:" & ex.Message)
        End Try


    End Function

在此处输入图像描述

4

2 回答 2

1

检查 $ORACLE_HOME 的权限:阅读更多内容:http: //oraclepoint.com/oralife/2010/08/19/oracle-odbc-connection-issue-of-system-exception-ocienvcreate-failed-with-return-代码 1-on-windows-with-asp/

于 2012-04-03T20:01:30.890 回答
0

您是否尝试过使用没有 TNSNames 的 ODP.Net?我发现这比在系统上处理 txt 文件要容易得多...

连接字符串看起来像这样:

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;

它与您放在 TNSNAMES 上的信息基本相同,但您将连接信息放在 web.config 上。

于 2012-04-04T03:42:18.110 回答