Solved

Connecting to Oracle

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

17 Experts available now in Live!

Get 1:1 Help Now