Connect to Oracle Database programmatically using .NET 2.0

I am a little confused about this. I have worked with SQL Server databases extensively and can make a connection as simple as below:

.NET 1.1
SqlConnection cn = new SqlConnection();
cn = new SqlConnection("server=localhost;database=test;uid=xxxx;password=xxxxx;");
cn.Open();

Now, that I am trying to work with Oracle databases, I run into problems. I read in .NET 2.0 that the same SqlConnection class can be used to connect to most relational databases. What do I need to do to the code to do this From my readings in .NET 1.0, the following had to be downloaded from MS in order to access an Oracle db:
.NET Framework Data Provider for Oracle

Is this still a requirement with .NET 2.0

Searched over the internet and most examples deal with SQL Server!!

Any help is appreciated!


Answer this question

Connect to Oracle Database programmatically using .NET 2.0

  • Jurgen

    So, are you saying I need to download the Oracle Data Provider I have browsed that site before. Thanks.

  • rgallazzi

    "The .NET Framework Data Provider for Oracle is an add-on component to the MicrosoftR .NET Framework version 1.0 that provides access to an Oracle database using the Oracle Call Interface (OCI) as provided by Oracle Client software."


    Is this still needed in .NET 2.0. Can anyone answer this question

    Thanks!


  • bhernacki

    Thanks, Dion. That is exactly the information I was looking for.

  • qtvali

    VS2005 comes with the Microsoft Oracle provider (System.Data.OracleClient) you do not need to download it.

    To use it in you program you need to add it to your references. Just go to add references and under the .Net tab select System.Data.OracleClient.

    You won't see any new components in the toolbox.

    Dion


  • smilyFace

    Thanks for the clarification. I have downloaded it from MS and installed it. I still dont see the new controls in the Toolbox How do I add this to the Visual Studio 2005 project. So far, I did a right-click on the tool bar and selected "Add Items" and tried pointing to the C:\program files\ms.net\oracleclient.net\ folder to point to the dll, but there seems to be no effect within VS 2005. Also, if I type "System.Data." I dont see "OracleClient" in the list. Any ideas!

    Sorry for the novice questions, I am coming back to .NET after a few years of J2EE coding.

    Thanks.

  • Alberto Grasso

    Yes one way or another you will need a provider for oracle...you can download this from oracle or from MS...

  • iffi raja

    www.connectionstrings.com


    • New version:
      "Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=asdasd;"


    • Old version:
      "Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;"


  • OLE DB, OleDbConnection (.NET)

    • Standard security:
      "Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;"
      This one's from Microsoft, the following are from Oracle
    • Standard Security:
      "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"


    • Trusted Connection:
      "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;"


  • OracleConnection (.NET)

    • Standard:
      "Data Source=MyOracleDB;Integrated Security=yes;"
      This one works only with Oracle 8i release 3 or later
    • Specifying username and password:
      "Data Source=MyOracleDB;User Id=username;Password=passwd;Integrated Security=no;"
      This one works only with Oracle 8i release 3 or later
    • Declare the OracleConnection:
      C#:
      using System.Data.OracleClient;
      OracleConnection oOracleConn = new OracleConnection();
      oOracleConn.ConnectionString = "my connection string";
      oOracleConn.Open();


      VB.NET:
      Imports System.Data.OracleClient
      Dim oOracleConn As OracleConnection = New OracleConnection()
      oOracleConn.ConnectionString = "my connection string"
      oOracleConn.Open()


      Missing the System.Data.OracleClient namespace Download .NET Managed Provider for Oracle >>
      Great article! "Features of Oracle Data Provider for .NET" by Rama Mohan G. at C# Corner


  • Connect to Oracle Database programmatically using .NET 2.0