The catch is that I want to provide the ability for users to connect to a database (either Access or SQL) at runtime, not at install time. Currently, users can create multiple Access databases (all with the same schema) and select which database they would like to connect to when logging in to the application. Going forward, I would like for users to be able to select either an Access or SQL database (having the same schema) to connect to and work with.
Here's what I was thinking...
1 - Generate DBSpecific projects for both Access and SQL.
2 - Include both DBSpecific projects in my sln, along with a generic DB project
3 - At runtime, determine the type of database that the user wishes to connect to. At that time, instantiate an instance of the DataAccessAdapter using a method such as this:
public static DataAccessAdapterBase adapter;
public static DataAccessAdapterBase CreateAdapter(string databaseType)
{
if (databaseType == "Access")
{
adapter = new AccessDAL.DatabaseSpecific.DataAccessAdapter();
}
if (databaseType == "SQL")
{
adapter = new SQLDAL.DatabaseSpecific.DataAccessAdapter();
}
return adapter ;
}
At this point, I "think" I should be able to switch adapters by calling this method.
I'm about to give it a try to see if it works.
My concern is that the generic model won't work for all situations due to datatype differences and differences in relationships between the Access and SQL database. As it turns out, the schemas are not entirely identical...I'm not able to create the same constraints in the SQL database as there are in the Access database.
Even more so, I'm concerned that I'll encounter unforeseen issues with this approach that will make go insane (I'm delicate like that). Really though, I have a deadline for this solution and I can't afford to do it wrong 3 times before getting it right.
Any insights, suggestions, warning flags, and or idiot alerts would be greatly appreciated.