VB.NET Cannot connect to Oracle Server

Go To StackoverFlow.com

0

I receive the error below when running the following function. The catch says the line where it opens the connection (Me.OracleConn.Open()).

I have made sure that the server exists in the TNSNAMES.ora file.

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

enter image description here

2012-04-03 19:55
by Jeremy F.
This is why Oracle consultants make a good living :) The error message googles well. And count the parentheses - Hans Passant 2012-04-03 20:34


1

Check the permissions of your $ORACLE_HOME: read more at: http://oraclepoint.com/oralife/2010/08/19/oracle-odbc-connection-issue-of-system-exception-ocienvcreate-failed-with-return-code-1-on-windows-with-asp/

2012-04-03 20:01
by johanvdw
I restored my computer back to a previous day when the Oracle client was working. I did see that the ORACLE_HOME was set to the wrong client - Jeremy F. 2012-04-06 14:40


0

Have you tried using ODP.Net without TNSNames? I find it quite easier than struggling with a txt file on your system...

The connection string would look something like this:

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

It's basically the same information that you put on the TNSNAMES but instead you put the connection info on your web.config.

2012-04-04 03:42
by Andrei Dvoynos
Ads