Connect to Oracle Database using SQLDataSource in ASP.NET c#
Step1) Download Oracle Data Provider for .NET OPD.NET
for 32-bit OPD.NET 32-bit
for 64-bit OPD.NET 64-bit
Download Oracle XE free version for Home User from Oracle
Step 2) Install Oracle and Oracle Data Provider tools for Visual Studio available in OPD.NET
Step 3) Add GridView to aspx page
Step 4) In The design mode click on New Data Source
Step 5) Choose Data Source Type as Database
Step 6) Click on New Connection
"Add Connection" Dialog box will come up.-> Click Change button
Step 7) Select "Oracle Database" Leave Default. Click OK
Step 8) Enter Oracle Credentials
Here Server Name: Localhost
User name: scott
Password:tiger
Step 9) Oracle Connection String
Step 10) Save That Connection String in Web.config
Step 11) Select Oracle Database Table Here I choose "EMP"
Click Next->Next->Finish
Step 12) Add Reference to System.Data.OracleClient
Step 13) Goto Web.config
Change from
<add name="ConnectionString"
connectionString="Provider=MSDAORA;Data Source=localhost;Password=tiger;User ID=scott"providerName="System.Data.OleDb" />
TO
providerName="oracle.DataAccess.Client" />
Step 14) Here is the SQLDataSource
<asp:SqlDataSource ID="HR" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [EMP]"></asp:SqlDataSource>
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
SelectCommand="SELECT * FROM [EMP]"></asp:SqlDataSource>
Step 15) Specify SQLDataSource ID in GridView
<asp:GridView ID="GridView1" runat="server" Width="459px" DataSourceID="HR"></asp:GridView>
Step 16) Run the Page.
Brilliant article..clear explanation...let me know if you have more articles like this.
ReplyDeletefinedinerecords at gmail dot com