BlueJay924 Posted October 5, 2003 Posted October 5, 2003 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. Quote
*Experts* Volte Posted October 5, 2003 *Experts* Posted October 5, 2003 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. Quote
*Experts* Nerseus Posted October 6, 2003 *Experts* Posted October 6, 2003 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 Quote "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
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.