There have been several times where I've needed to create an architecture
that is database agnostic. For example, a solution that could use either SQL
Server or an Oracle backend. With .NET 1.x, there are things you can do such as
leverage common base classes or interfaces similar to the
.NET Petshop example. This is implemented by using the
factory design pattern, and a "plug-in" allowing you to make a simple
configuration setting change to switch database types on the fly or when rolling
out the solution. Another way I've achieved this is to use
LLBLGen Pro's
adapter configuration.
Fortunately, you can achieve this design goal very easily with the .NET
Framework 2.0 using DB Provider Factories. Below is an example of how you can do
this. First is the App.config settings followed by code...
<?xml
version="1.0"
encoding="utf-8"
?>
<configuration>
<connectionStrings>
<add
name="Northwind"
providerName="System.Data.SqlClient"
connectionString="Data
Source=.;Initial Catalog=Northwind;
integrated security=SSPI"
/>
</connectionStrings>
</configuration>