Integrate an ASP.NET Web Application With Oracle
on using Oracle with Visual Studio and ASP.NET covers the
database access and data manipulation from Visual C#. Security
(whilst important) are beyond the scope of this tutorial.
Install Visual Studio 2008 for
building your application
Oracle Database 10g XE. Make sure that you follow the instructions to
enable the HR database. If you accepted the default settings
installer, the server
is in C:\oraclexe. The
tnsnames.ora files are in
3. Start the database
4. Install 11g Data Access Components (ODAC) for
Visual Studio 11.1.07.20 or later. If you accepted the default
settings of the installer this is installed in c:\app.
6. Copy listener.ora, sqlnet.ora and tnsnames.ora to
c:\app\product\11.1.0\client_1\Network\Admin to enable the application
to connect to the database and to
prevent a TNS-12514:
TNS: could not resolve the connect
How To Create Your ASP.NET Web Site
Watch the above video and see how to do it in real time.
Start Visual Studio 2008
Web Site from the menu
You will see the list of templates appear on
the "New Web Site" page.
Select the "ASP.NET website" template; Visual C# as the
language and set the location to "c:\MyFirstWebSite"
on the Design tab when you see the “Default.aspx” page in your
new ASP.NET web site. Your screen should look like
Move the mouse over the Toolbox tab to bring up
SKYROCKET Your Career!
If you're not
already a subscriber
Tips & Tricks you're missing out on a
myriad of tips and techniques to help
you become a better, faster, smarter developer. Subscribe now and ignite your
Expand Data and drag
the GridView control to the canvas so that it appears
Next click the ">"
to bring the GridView Tasks into view
if it is not already and select <New
data source…> from the drop down box.
This starts the Dat Source Configuration Wizard
as shown below. Choose Database as the Data source type, enter
"HR" as the ID and click “OK” to advance to the next screen.
Click on the "New Connection" button to bring
up the Add Connection screen.
On the Add Connection screen, click
on the “Change…” button.
In the Change Data Source
box ensure the Data source and the Data provider are set
correctly as shown in the following screen shot. Tick
“Always use this selection” and click
Back on the "Add Connection" screen, set the
Data Source Name to “HR.XE” and enter
both the user name and the password fields in the connection details
Ensure all the details have been
entered/set correctly by
clicking on the "Test
Connection" button. If an error message appears ensure the database is
running, all the details have been entered correctly and that ODAC has
been installed as per step 4 of the pre-requisites. If the test
succeds the following message box will pop up.
the OK button then click Next on the Configure Data Source
and click Next again to save the connection string and advance to
configuring the select statement
To configure the select statement,
select DEPARTMENTS from the
Names drop down list and select “*” from the columns list to
retrieve all columns from the departments table when the query is run.
click the “Next” button to bring up the test query screen.
“Test Query” dialog box appears with the select statement that you
created in the previous step. Click the “Test Query” button to
run the query and display the results.
Click "Finish", to display the Data Grid View,
then click the “Enable Paging”
check box in the Grid View Tasks panel.
Navigate to Build->Build
Web Site on the menu to build your ASP.NET web site.
Assuming the build is successful, navigate to
Debugging” to run and test your web site.
Enable debugging in the web.config file and
causes the results of your query to appear in a browser. That's it -
you've succesfully built an ASP.NET web site and connected it to the
instructor-led training to learn SQL, PL/SQL,
database administration, Linux/Unix system administration?