How to access oracle database using Enterprise Library

Topics: Data Access Application Block
Dec 15, 2008 at 1:06 PM
Hello masters, I am trying first time to access the oracle database using Enterprise library and honestly could't find any good code examples in the help supplied with the installation may be over looked, so realized to post my probelm here to get some quick answers.

1, How can I configure my connection string for oracle i mean username password and database name.
2, how can I execute a query and stored procedure against ORACLE using enterprise libary, is it same like SQL server.

Thanks and best regards
Dec 15, 2008 at 2:40 PM
Add a Data Access Application block, add a Connection String. (sample oracle connection string -

Here's a sample code on how to use the connection string you've just added (with the name "OracleDb").

Using the generic Database class:
Database db = DatabaseFactory.CreateDatabase("OracleDb");
DbCommand oracleCommand = db.GetSqlStringCommand("Your select statement here...");
DataSet ds = oracleCommand.ExecuteDataSet();

Or the OracleDatabase class: (Add a reference to System.Data.OracleClient)
OracleDatabase database = DatabaseFactory.CreateDatabase("OracleDb");
OracleCommand oracleCommand = database.GetStoredProcCommand("sp_Get"); //creates an OracleCommand of CommandType stored procedure.
DataSet ds = oracleCommand.ExecuteDataSet();

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.

Dec 16, 2008 at 7:24 AM

Thanks Sarah for the prompt reply, I have tried your suggested code but guess what I am getting error below is the detial of what I am doing and what I am getting.

1. Connectionstring I am using to access my oracle database server is


<add name="SqlServer" connectionString="Data Source=hocustomer01;Initial Catalog=customer;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="OracleServer" connectionString="Data Source=custdevserver;Password=custuser123456;user id=custuser;Max Pool Size=300;Min Pool Size=20" providerName="System.Data.OracleClient" />

 2. executing code.

            DataSet tempDataSet;            
            string sql = "select * from customer where custid=0123456";           
            Database oracleDatabase = DatabaseFactory.CreateDatabase("OracleServer");
            DbCommand oracleCommand = oracleDatabase.GetSqlStringCommand(sql);
            tempDataSet = oracleDatabase.ExecuteDataSet(oracleCommand);
            _logger.Info("tempDataSet = " + tempDataSet.Tables[0].Rows.Count);


so after executing the above mentioned code I am getting error.(System.Data.OracleClient requires Oracle client software version 8.1.7 or greater.)

I am using enterprise library 4.0.
kindly guide what I am missing



Dec 16, 2008 at 7:44 AM

Here are some possible causes and solutions to your error, see this links:

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.