SQLCommand/SQLConnection vs OleDbCommand/OleDbConnection

倖福魔咒の 提交于 2019-12-14 00:55:42

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/2273609/sqlcommand-sqlconnection-vs-oledbcommand-oledbconnection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!