运行以下功能时,我收到以下错误。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