Solved

Connecting to Oracle

Posted on 2004-08-31
5
553 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
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.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now