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 connecting to an Oracle database server.This article contain very basic and simple steps for the connectivity.

I came across this article : http://msdn.microsoft.com/en-us/library/ms971506.aspx which helped enourmously, and used quite a bit of it in achieving my own solution. The code and conetent below is a combination from the MS article and my own work in making it work.

It is assumed that developers know the concept of TNSNAMe.ora file on Oracle /admin/Netwrok folder where connetions for the database with IP and Port are declared. the same database connection need to use here.

8. Remember to close the connection when you are done
oraconn.Close();

9. If you are retrieving a result set, create a DataSet, DataTable, or DataReader
Open the connection and execute the stored procedure using one of the Execute methods of the OracleCommand object shown below:

1.ExecuteReader : Builds an OracleDataReader by executing a stored procedure that returns a result set
2.ExecuteNonQuery : Executes a query or procedure that does not return a result set returning the number of rows affected.
3.ExecuteOracleNonQuery : Executes a query, returning the number of rows affected.
This method also uses an OracleString parameter to return the row id for the last row modified by an UPDATE, INSERT, or DELETE query.
4.ExecuteScalar: Executes a query or procedure and returns either the return value or the value of the first column of the first row of the result set as a .NET Framework data type.
5.ExecuteOracleScalar : Executes a query or procedure and returns either the return value or the value of the first column of the first row of the result set as an OracleType data type

The Oracle .NET data provider makes it easy to execute stored procedures and access the return values, whether they are one or more scalar values or result sets. You can use Oracle procedures together with the OracleDataAdapter to fill a DataSet, work with the disconnected data, and update the changes to the Oracle database at a later time.

You can also go thorugh the Article for Asp.net to SQl connectivity, which is helpul for new deveopers.

Featured Post

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Wrapper-1-Query. Use an Excel function to calculate a column for an Access query. Part 1. Shows a query in Access that has a calculated column with the results of an Excel worksheet function.
See how to call a wrapper function from a query, and …