I have a situation , I am sure about the best approach for it. I have a database application that is designed to handle both SQLServer database and Oleddb "Access mdb" database. the issue is that during application start up , the application detects the configuration file and decides which database to use , eg , oledb to Sqlclient objects. the problem is that the application itself is, eg code to use teh sqlclient objects at different locations of the program. If i need to use oledb , i need to replace all of the sqlclient objects with oledb. who can i do it at run time. the bad solution will be to make at make both objects and decide which one to use , but the application is large. so it will be un-logic to use this approach. I tried to define an object as below
Public aa As SqlClient.SqlConnection Public bb As OleDb.OleDbConnection Public gg as object if applicType="AccessDatabase" then directcast(gg,oledib.oleDbConnection")
but this gave me an error .
I tried also :
if applicType="AccessDatabase" then directcast(aa,oledib.oleDbConnection")
but gave an error that I can not cast sqlclient to oledb .
Any solution ?