Can anybody help with this problem?
I am writing a database class that allow the user to supply database connection and command information to it. The query I have is that I want it to work with both SQL and Access and would like to avoid using different coding routines for both as they predominently do the same thing hence:
SQL Access
SqlConnection mySQL; OdbcConnection myODBC;
mySQL = new SQLConnection(connection); myODBC = new OdbcConnection (connection);
mySQL.Open() myODBC.Open();
and so on...
Is it possible to define myDB as say a base object of some description and then set it to either SQL or ODBC when it recognizes the format of the connection string?
Thanks in advance
Mamta MPosted Oct 30, 2008, 4:33 AM
Yes, this is possible.
You can make use of the parent DbConnection class to create a common DB object and then based on the Provider value specified in the connection string, you can set the specific connection values. Of course, this scheme will work only if the connection string has a Provider keyword specified along with a corresponding value.
Regards,
Mamta