I meant something like this:
//strDB takes in value from the config file of whether the DB is
Oracle or Sql
//this code being in data access layer would require the input and
output values
//from and to business logic layer
//so though the code might be kind of repetitive but I think migrating
the DB from
//one to another one would require the change only in the config file
if(strDB.Equals("sql"))
{
SqlConnection con = new SqlConnection(connectionString);
con.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM
Customers",con);
SqlDataReader reader = cmd.ExecuteReader();
//operations on reader object
}
else if(strDB.Equals("oracle"))
{
OleDbConnection con = new OleDbConnection(connectionString);
con.Open();
OleDbCommand cmd = new OleDbCommand("SELECT ename,job FROM
emp",con);
OleDbDataReader reader = cmd.ExecuteReader();
//operations on reader object
}
On Nov 26, 8:50 am, Stephen Russell <[email protected]> wrote:
> On Thu, Nov 25, 2010 at 2:37 AM, Samresh <[email protected]> wrote:
> > I think you can do something like this.
>
> > Put a Key Value pair in web.config which holds some value that defines
> > what database needs to be connected to.
> > Design your Data Access Layer such that the it checks for that value
> > if value says Access database use OleDb objects to handle the db
> > operations
> > else if value says SQL server database use Sql objects to handle the
> > db operations.
>
> ------------------------------
>
> Your syntax between Oracle and SQL Server is going to be the issue of
> most pain, not the connector.
>
> --
> Stephen Russell
>
> Sr. Production Systems Programmer
> CIMSgts
>
> 901.246-0159 cell