How should I connect to an oracle database 10I

I will be using VB.NET and I am not sure how I should setup the environment.          

Say I have this in my app.config file.


<add key="EMMainDBConn" value="Data Source=ORACLEDBA; Initial Catalog=EMREPORTING; user id = User; password=Password;"></add>
Now if this was an sql datasource it would go like so?

         ''create a connection to the financial solutions database if needed
        '''' Me.Text = clsRunParms.FullNamefromNetwork()
        If _cnnFinSol Is Nothing Then
            _cnnFinSol = New System.Data.SqlClient.SqlConnection
            _cnnFinSol.ConnectionString = clsRunParms.FinSolMainDBConnString
        End If

What type of connection do I use and how do I use it?

I will have to interface with oracle on a linux server. I will need some code to practice with.

mathieu_cuprykAsked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
You can use something like:

    Imports System.Data.OracleClient

    Sub Main()
        Dim oOracleConn As OracleConnection = New OracleConnection()
        oOracleConn.ConnectionString = "my connection string"
        oOracleConn.Open()
    End Sub


The fact that your Oracle DB is on Linux rather Windows is irrelevant. The communications protocols for the DB are the same regardless of the OS it happens to be running on.
0
 
Carl TawnSystems and Integration DeveloperCommented:
You need to use the OracleConnection object, with an appropriate Oracle connection string, which you can find here:

    http://www.connectionstrings.com/

If you look under the Oracle connection string you will also find sample code for the connection.
0
 
mathieu_cuprykAuthor Commented:
For my project  should I use OLEDB  .NET, OracleConnection (.NET) , or ODBC?

0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Carl TawnSystems and Integration DeveloperCommented:
Either OLEDB.Net or OracleConnection is best, ODBC is a lot slower than the other two.
0
 
mathieu_cuprykAuthor Commented:
U got me confuse. I have to connect  to a linux system running oracle 10i.

I should have no problem using the oracle connection?

0
 
mathieu_cuprykAuthor Commented:
Looks good, do you have any programs I can take a look at for practice?

0
 
Carl TawnSystems and Integration DeveloperCommented:
Afraid not, don't have access to an Oracle server at the mo. But a quick sample of how you would retrieve data would be something like:

    Sub Main()

        '// Create and open a connection
        Dim oOracleConn As OracleConnection = New OracleConnection()
        oOracleConn.ConnectionString = "my connection string"
        oOracleConn.Open()

        '// Create and execute a Command
        Dim oCmd As New OracleCommand("SELECT * FROM YourTable", oOracleConn)
        Dim oDR As OracleDataReader = oCmd.ExecuteReader(CommandBehavior.CloseConnection)

        '// Loop through all records
        While oDR.Read()
            Console.Write(oDR.GetValue(1))
        End While

        '// Dispose the datareader (also closes DB connection for us)
        oDR.Dispose()

    End Sub
0
 
mathieu_cuprykAuthor Commented:
Looks good but how do I add the driver to the odbc. Do I have to install the client oracle?

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.