SqlCommand.Dispose()将释放使用的事务 [英] Will SqlCommand.Dispose() releases the Transaction used

查看:501
本文介绍了SqlCommand.Dispose()将释放使用的事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在使用SqlCommand在C#.net中执行查询,并且还为其分配了Command Transaction.执行完查询后,我将调用SqlCommand.Dispose(),这会影响我的交易吗?因为我正在使用同一事务进行进一步执行.

以下是我的代码:

Hello, I am using the SqlCommand to execute my query in C#.net and also I am assigning Command Transaction to it. Once after executing my query I am calling SqlCommand.Dispose(), will it effect my transaction? Because I am using the same transaction for further execution.

Below is my code:

SqlCommand cmd=new SqlCommand(query,connection);
cmd.CommandTimeOut=0;
cmd.Transaction="Some tranaction";
cmd.ExecuteNonQuery();
cmd.Dispose();



执行此代码后,我将使用同一事务来进一步执行查询.

请帮助
谢谢



After this code execution I am using the same transaction for further execution of queries.

Please Help
Thank You

推荐答案

阅读下面的链接
http://forums.asp.net/p/1132352/3955967.aspx [ ^ ]
Read The below Link
http://forums.asp.net/p/1132352/3955967.aspx[^]


这篇关于SqlCommand.Dispose()将释放使用的事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆