运行以下功能时,我收到以下错误消息。 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
答案 0 :(得分:1)
检查$ ORACLE_HOME的权限:阅读更多内容: http://oraclepoint.com/oralife/2010/08/19/oracle-odbc-connection-issue-of-system-exception-ocienvcreate-failed-with-return-code-1-on-windows-with-asp/
答案 1 :(得分: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上。