?
Solved

How should I connect to an oracle database 10I

Posted on 2006-05-08
8
Medium Priority
?
190 Views
Last Modified: 2010-04-23
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.

0
Comment
Question by:mathieu_cupryk
  • 4
  • 4
8 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16633138
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
 

Author Comment

by:mathieu_cupryk
ID: 16638539
For my project  should I use OLEDB  .NET, OracleConnection (.NET) , or ODBC?

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16638551
Either OLEDB.Net or OracleConnection is best, ODBC is a lot slower than the other two.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mathieu_cupryk
ID: 16638609
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
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 16638648
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
 

Author Comment

by:mathieu_cupryk
ID: 16638744
Looks good, do you have any programs I can take a look at for practice?

0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16638792
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
 

Author Comment

by:mathieu_cupryk
ID: 16639045
Looks good but how do I add the driver to the odbc. Do I have to install the client oracle?

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question