Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 I'm 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

if(computer.speed == "slow")
    {  
       hamster.feed();  
    }
if(computer.speed == "really slow")
    {  
        hamster.kill();
        BuyNewHamster();
    }

  • Administrators
Posted

Ideally you wouldn't 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.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...