执行Commit tran语句 [英] Executing the Commit tran statement

查看:201
本文介绍了执行Commit tran语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在例程中做了一些插入和删除操作,如果它们都成功了,我想提交事务,否则回滚.
如何从代码中执行此操作-我的意思是,如果我使用数据适配器,则它具有SelectCommand/InsertCommand/DeleteCommand/UpdateCommand.
应该是UpdateCommand,还是我需要使用其他东西?
谢谢,

Ekjon

I did some inserts and deletes in my routine and if they are all successful, I want to commit the transactions, else rollback.
How do I do it from my code - I mean if I use a Data Adapter, it has SelectCommand/ InsertCommand/DeleteCommand/UpdateCommand.
Should it be UpdateCommand, or I need to use something else?
Thanks,

Ekjon

推荐答案

[
This[^] from MSDN should give you enough to work out what you should do.

Although it beats me why my search results should be any better than your own. You did search before asking, didn''t you?


看看 TransactionScope类 [
Have a look at System.Transactions Namespace[^]. Especially TransactionScope Class[^]. I believe that this approach would nicely wrap your operations into a single unit-of-work.


这篇关于执行Commit tran语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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