How can I do a comum DAL to access SQL, Oracle, Access, etc

  • Thread starter Thread starter Fernando Lopes
  • Start date Start date
F

Fernando Lopes

Hi.
I want to develop a class (my Data Access Layer) to access all database what
am I want (like Oracle, SQL Server, Access, MySQL)

Someone did anything like that? Or know how can I do that?
I hear something about Pet Shop 3 model access each Oracle than Sql Server.
The model they are utilized were correct?

Thanks.

Fernando Lopes
 
I have this exact same requirement for my Data Access Layer.

Check the Data Access Application Block 3.0 (Abstract Factory)
They implement a "helper" class that will help you program with ADO.NET
using the common interfaces.

For instance this code uses the SQL Server provider:

string providerType = "SqlServer";

AdoHelper helper = AdoHelper.CreateHelper(providerType);
IDbConnection myConnection = helper.GetConnection(connString);
IDbCommand myCommand =
helper.CreateCommand(myConnection, "SELECT * FROM Customer");

If you wanted to use OleDb all you would need to do is change "SqlServer" by
"OleDb", .. hence, you can take runtime decision on which provider to use, ..
say according to a configuration file or register parameter etc...

Hope this helps
 
Back
Top