6

Does it make a difference whether I use SQLCommand/SQLConnection instead of OleDbCommand/OleDbConnection. Do I get any advantages out of that, from a API comfortability, feature, performance or security perspective? Or any other perspective?

2 Answers 2

5

OleDbCommand and OleDbConnection are general. SqlCommand and SqlConnection are specific to SQL Server, and can take advantage of its features. They also expose the features of SQL Server. For instance, you can use them to manipulate XML columns.

1
  • 3
    Yes, but what are those features?
    – bitbonk
    Commented Feb 18, 2010 at 12:34
1

with sqlconnection you can use transactions and transaction scopes like:

using(var scope = new TransactionScope())
{

//do a lot of stuff with sqlconnection/sqlcommand (s)

scope.Complete()
}

you need to have the msdtc service enabled for this to work

look here http://valueinjecter.codeplex.com/, at the Data Access Layer page where I show this

1
  • But OleDB has transactions too. I can pass a transaction to multiple commands, commit them and roll them back. What is the advantage of the above? Just nicer to read?
    – bitbonk
    Commented Aug 24, 2010 at 18:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.