C#中的交易? [英] transactions in c# ?

查看:92
本文介绍了C#中的交易?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在后端存储过程中或在c#中的前端中有事务更好吗?

谢谢

Hi,

Is it better to have transactions in back end stored procedures or front end in c#?

Thanks

推荐答案

交易仅在服务器上,但是您可以在任何地方启动它们.

在客户端上,您可能会获得连接超时,该超时将自动回滚事务.
Transactions are on servers only, but you can start them anywhere.

On the clients you might get connection timeouts which will automatically rollback the transaction.


如果您正在谈论ADO,则可以使用SqlConnection.BeginTransaction或类似的方法启动事务,我想那就是你的意思.我之所以争辩是因为您想要使事务尽可能小且快速,最好在数据库中进行.这些也导致更好的封装,因为您的数据库黑匣子"在事务上是健全的.
If you''re talking ADO, you can start a transaction with SqlConnection.BeginTransaction or something like that, I presume that''s what you mean. I''d argue because you want to keep transactions as small and fast as possible its better to do them in the database. These also leads to a better encapsulation in that your database ''black-box'' is transactionally sound.


Google是您的朋友!
在CP 在ADO.NET中使用事务 [ ^ ]
MSDN在事务 [分布式事务 [ TransactionScope [在SP或ADO.NET中使用事务? [
Google is your friend!
There is a nice article on Transactions right here on CP Using Transactions in ADO.NET[^]
MSDN also has sufficient sources on Transactions[^]
You might also be interested in Distributed Transactions[^] and TransactionScope[^]
Use Transactions in SP''s or ADO.NET?[^] I think the most important thing is that a Transaction actually does what it does, which is making sure actions are rolled back if an exception occurs!
If you want to use it in an SP or in code kind of depends on you and your situation.
Hope this helps :)


这篇关于C#中的交易?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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