1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

connecting to oracle 10g client from visual studio 2008

Discussion in 'Other Development Tools' started by sadiyarani, Feb 28, 2009.

  1. sadiyarani

    sadiyarani Active Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    55
    how oracle 10g client can connect with visual studio 2008
     
  2. sadiyarani

    sadiyarani Active Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    55
    hi , i hav a problem.I don't know how to connect visual studio 2008 from oracle 10g
     
  3. sadiyarani

    sadiyarani Active Member

    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    55
    pls forward the answer
     
  4. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240
    hi please don't double post. There exist four main methodologies to access Oracle database from a .NET application:

    * Microsoft’s .NET data provider for ODBC (or ODBC.NET)
    * Microsoft’s .NET data provider for OLEDB (or OLEDB.NET)
    * Microsoft’s .NET data provider for Oracle
    * Oracle’s data provider for .NET (or ODP.NET)

    The most preferred out of these are Microsoft’s .NET data provider for Oracle and Oracle’s data provider for .NET (or ODP.NET).

    Microsoft’s .NET data provider:

    Before using this data Provider you need to add a reference to the assembly System.Data.OracleClient. You can use the following code to connect to Oracle after making a reference Imports System.Data.OracleClient
    Code (Text):

    Public Class Oracle_conn
    Private Sub btnConn_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    btnConn.Click
    Dim conn As New OracleConnection
    conn.ConnectionString = "Data Source=xe; User Id=scott;Password=tiger;"
    -----
    -----
    Try
       'try connecting to oracle
        conn.Open()
      'close the connection before exiting
       conn.Close()
    MessageBox.Show("Connected to Oracle")
    Catch ex As Exception
    'If connection failed display an error
    MessageBox.Show("Unable to connect. " & ex.Message)
    End Try
    End Sub
    End Class
     
     
  5. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240
    To use Oracle’s data provider for .NET (or ODP.NET) method you need to download ODP.NET from web and install on your system. Here again, you need add a reference to this assembly from visual studio. Once a reference has been added , you can proceed with the following code to connect to Oracle database using ODP.NET
    Code (Text):

    Imports oracle.DataAccess.Client
    Public Class Oracle_conn
    Private Sub btnConn_Click(ByVal sender As
    System.Object, ByVal e As System.EventArgs) Handles
    btnConn.Click
    Dim conn As New OracleConnection
    conn.ConnectionString = "Data Source=xe;User Id=scott;Password=tiger;"
    Try
       'try connecting to oracle
        conn.Open()
      'close the connection before exiting
       conn.Close()
    MessageBox.Show("Connected to Oracle")
    Catch ex As Exception
    'If connection failed display an error
    MessageBox.Show("Unable to connect. " & ex.Message)
    End Try
    End Sub
    End Class
     
     
  6. sameer

    sameer Forum Advisor

    Messages:
    105
    Likes Received:
    6
    Trophy Points:
    240