什么是SQL事务之间在存储过程级别,一个在SqlConnection的水平的差异?存储过程、差异、级别、水平

2023-09-03 07:19:00 作者:丟ㄋ少年矢ㄋ心

假设使用 BEGIN TRANSACTION / COMMIT事务 MSSQL Server上的存储过程使用的SQL事务,如何从一开始的不同,并通过 SqlConnection.BeginTransaction()?

Say a stored procedure on MSSQL Server uses an SQL transaction using BEGIN TRANSACTION/COMMIT TRANSACTION, how does that differ from beginning and commiting one using ADO.NET via SqlConnection.BeginTransaction()?

推荐答案

有关ADO.NET,它是没有什么区别。它隐含在MSDN中规定凡的SqlTransaction对象的Commit方法被说成失败,如果该事务已回滚在服务器上。

For ADO.NET, it's no difference. It's implicitly stated in MSDN where for SqlTransaction object the Commit method is said to "fail if the transaction has already been rolled back on the server."

此外,SQL Server事件探查器显示事务隔离级别设置提交读; BEGIN TRAN。当你连接上执行.BeginTransaction尽快

Also, SQL Server Profiler shows "SET TRANSACTION ISOLATION LEVEL READ COMMITTED;BEGIN TRAN" as soon as you execute .BeginTransaction on a connection.

有关ADO(不是.NET),然而,事实并非如此。那为了使用,有效的,嵌套事务(服务器跨嵌套在里面的客户端的)漂亮的场景。尽管我已经使用了很多,我不能确切定义什么是客户端事务就是在这种情况下。

For ADO (not .NET), however, it's not. That used to allow nice scenarios with, effectively, nested transactions (server trans were nested inside client ones). Despite I have used that a lot, I can't define exactly what a "client transaction" was in that case.