Allow for multiple database types

dakota97

Well-known member
Joined
Nov 14, 2003
Messages
113
Location
Pennsylvania
Hi all,

Is there a way that you can allow you a form to connect to multiple database types by creating a separate database class in C#?

What Im aiming to do is create a data class that has the connection information for both an OleDb and SQL database connection. I want to be able to allow a form to connect to the appropriate database type based on the information that is included in the data class. For example, I have 2 separate projects in my solution. The first project is my Windows Application. The second is a class library. My library includes a data class, and in the data class I have a public string property that returns the type of database that is being used. Then, I would like the form to have the ability to open the correct type of connection to the database, based on the value that is returned from the property.

My main reason for this is due to the fact that later on, if I decide to change the database type, I could edit the data class, and send out an updated class library without having to go through and package up the entire application. Any suggestions would be appreciated.

Thanks in advance,

Chris
 
Ideally you wouldnt want to return any database specific information to the front end from your classlibrary - just have methods that return / accept the data types your business logic uses.
The data access library should completely hide and abstract away the underlying DB type.

One thing you could do is make the classlibrary as DB neutral as possible and develop a plugin style system to handle the DB specific functionality (connections, commands etc.), this way when you need to support a new or different DB vendor you only need to (re)write the DB specific functionality and nothing else needs to be modified or re-deployed.
 
Back
Top