locked
Connect to an Oracle Network Server RRS feed

  • Question

  • User-1995885001 posted

    I have a Windows 7 dev machine used to create .Net applications with VS 2010.  I want to connect to a remote server (on the same network running Windows 2003 Server) that is running an Oracle 10g database.  I also need to mention (just in case) that the remote server is also hosting an MS SQL 2005 application as well.  I am using the code below (with the first connection string) to connect directly to a version of 10g that is running on the same machine with no problems, however when I try to connect to the network machine, it actually crashes Windows 7.  What concerns me is that I have dual try/catch statements in the application and I do not understand why it simply does not refuse the connection and report the error. I have tried several variations of connection strings as I feel that I must be making a sytax error somewhere.  I suppose the real question is 'what is the correct syntax for the connection string'....or WHATEVER the hell I am doing wrong.  This is my first go around with Oracle (and I am not liking it at all), but it is not a matter of choice for me.  SO.........any help or suggestions are greatly appreciated.  Thank you in advance...Best Regards, Pat

          

            //Class Variables
    //string CONNSTR = "Server=127.0.0.1:1521;User ID=Patt;Password=Mine;";
    string CONNSTR = "Server=192.168.2.5:1521;User ID=Patt;Password=Mine;";

    public Oracle()
    {
    InitializeComponent();
    }

    //Methods
    private void TestMyOracleConnection()
    {
    OracleConnection Conn = new OracleConnection(CONNSTR);
    try
    {
    Conn.Open();
    MessageBox.Show("Oracle Connection Established", "Success");
    }
    catch (OracleException ex)
    {
    MessageBox.Show(ex.Message, "Oracle Connection Failed!");
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.Message, "Oracle Connection Failed!");
    }
    finally
    {
    Conn.Close();
    MessageBox.Show("Oracle Connection Closed", "Success");
    }
    }

    private void buttonTestConnection_Click(object sender, EventArgs e)
    {
    TestMyOracleConnection();
    }


    Sunday, December 19, 2010 4:29 PM

Answers

  • User-1181492241 posted

    In the connection string you need to use Data source instead of Server.

    string CONNSTR = "Data Source=192.168.2.5;User Id=Patt;Password=Mine;";

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 19, 2010 8:22 PM

All replies

  • User-1181492241 posted

    In the connection string you need to use Data source instead of Server.

    string CONNSTR = "Data Source=192.168.2.5;User Id=Patt;Password=Mine;";

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, December 19, 2010 8:22 PM
  • User269602965 posted

    And after using the correct IP address instead of local host 127.0.0.1,

    you may also encounter firewall issues with PORT 1521 Oracle Listener,

    depending on firewall setting in Windows 2003 and any firewalls between application and database. 

    Monday, December 20, 2010 11:49 AM