Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
i'm currently using an Access database but i eventually want to swtich to microsoft sql server database. do i have to use sqlconnection if i switch to microsoft sql server? i'd prefer to use oledbconnection if it would satisfy both databases.
  • *Experts*
Posted
You have to use SqlConnection to connect to an SQL Server databases, yes. If you need to be able to store a connection from any kind of database, store it in an IDbConnection object, but remember that since IDbConnection is just an interface, it cannot be used by iteslf. It can only be used to hold a database connection object which has been previously defined.
  • *Experts*
Posted
You have to use SqlConnection to connect to an SQL Server databases

 

That's not true at all - you can definitely use the OleDbConnection object to connect to SQL Server. The SQL Server specific connection offers better performance and some extra features (I don't know them offhand, only read about them) which is why you usually code against it when connecting to SQL Server.

 

But Volte has a good point about making your connection code generic, to a point. You can code an abstraction layer which uses IDbConnection or you can simply wrap the Connection and other DB Specific calls somehow (maybe a webservice, maybe a class, who knows). You normally don't care how you get the data, just that it ends up in a DataSet (for example) and can be used to update the database eventually.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

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...