Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLCommand/SQLConnection vs OleDbCommand/OleDbConnection

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?

like image 880
bitbonk Avatar asked Feb 16 '10 14:02

bitbonk


People also ask

What is the difference between OleDbConnection and SqlConnection?

SqlConnection is designed to access SQL Server, while OleDbConnection is designed to access any database.

What is the name of command class in case of Oledb data provider?

OleDbCommand Class (System. Data.


2 Answers

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.

like image 194
John Saunders Avatar answered Oct 28 '22 11:10

John Saunders


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

like image 35
Omu Avatar answered Oct 28 '22 11:10

Omu