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

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
 
F

Fernando Lopes

Thanks Michael.
I know this on ado.net 2.0
But I'm using 1.1

Any other idea?
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top