Solved

Connecting to Oracle

Posted on 2004-08-31
5
584 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
  • 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 125 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
i have to take the screenshot of command prompt? how to do this? 1 58
ASP.NET MVC - Views 3 38
How to repeat the data 4 30
Securing WEBAPI on Azure 2 18
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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