?
Solved

Connecting to Oracle

Posted on 2004-08-31
5
Medium Priority
?
596 Views
Last Modified: 2008-02-26
Hi,

I am trying to learn ASP.Net, but I have been unable to connect and return records from an Oracle database.  I have Oracle connection string which I use with ADO and VB.

DB_Connect = "Provider=MSDAORA.1;Password=project;User ID=project;Data Source=ext5.world"

Thanks for any help

Damien.
0
Comment
Question by:damienm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11941026
         o



#  Oracle

    *  ODBC


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


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


    *  OLE DB, OleDbConnection (.NET)


          o  Standard security:
            "Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;"

                This one's from Microsoft, the following are from Oracle

          o  Standard Security:
            "Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"


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


    *  OracleConnection (.NET)


          o  Standard:
            "Data Source=Oracle8i;Integrated Security=yes;"

                This one works only with Oracle 8i release 3 or later

          o  Specifying username and password:
            "Data Source=Oracle8i;User Id=username;Password=passwd;Integrated Security=no;"

                This one works only with Oracle 8i release 3 or later

          o  Declare the OracleConnection:

                C#:
                using System.Data.OracleClient;
                OracleConnection oOracleConn = new OracleConnection();
                oOracleConn.ConnectionString = "my connectionstring";
                oOracleConn.Open();



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

    *  Core Labs OraDirect (.NET)


          o  Standard:
            "User ID=scott; Password=tiger; Host=ora; Pooling=true; Min Pool Size=0;Max Pool Size=100; Connection Lifetime=0"

                Read more at Core Lab and the product page.

    *  Data Shape


          o  MS Data Shape:
            "Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;user id=username;password=mypw"

                Want to learn data shaping? Check out 4GuyfFromRolla's great article about Data Shaping >>

http://www.connectionstrings.com/

Any error message would also be helpful.

Regards,

Aeros
0
 
LVL 2

Author Comment

by:damienm
ID: 11941973
Hi,

I need more than the connection string code, I don't know asp.net very well at all, so some sample code which outputs something to the screen from a table in Oracle would be good.

Damien
0
 
LVL 17

Accepted Solution

by:
AerosSaga earned 375 total points
ID: 11942046
outputting to a screen will be the same no matter what.  You will need to decide which provider you will be using for your connection from above and then your code will look something like this.  You will just swap out where it says sql client with your oracle provider of choice:
***The astricks are the parts you will need to change once you decide on your provider
 Private Sub LoadProductData()
        Dim cnn As New ByteFX.Data.MySqlClient.MySqlConnection(ConfigurationSettings.AppSettings("SiteDB")) ****
        Dim cmd As New ByteFX.Data.MySqlClient.MySqlCommand*****
        Dim dr As ByteFX.Data.MySqlClient.MySqlDataReader******
        cmd.CommandType = CommandType.Text
        cmd.CommandText = "SELECT * FROM CustomerTracking WHERE SessionID = '" & Me.lblTrackingID.Text.ToString & "'"
        cmd.Connection = cnn
        cnn.Open()
        dgCart.DataSource = cmd.ExecuteReader
        dgCart.DataBind()
        cnn.Close()
        cmd.Dispose()
        cnn.Dispose()
    End Sub
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 11942064
your connection string goes in your web.config file like so:

<appSettings>
<add key="SiteDB" value="Persist Security Info=False;database=MyDB;server=63.XXX.XX.XX;user id=root;pwd=XX"></add>
      </appSettings>
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 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