了解 Windows 中的 MSDTC
要在 Subsonic 中使用事务构造(如下),MSDTC 需要在 Windows 计算机上运行。正确的?
using (TransactionScope ts = new TransactionScope())
{
using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
{
// update table 1
// update table 2
// ts.commit here
}
}
- MS-DTC 是 Windows 系统(XP、Vista、Windows 7、服务器等)上的默认服务吗?
- 如果未启用,我如何确保它在应用程序的安装过程中启用?
To use transaction construct(as follows) in Subsonic, MSDTC needs to be running on Windows machine. Right?
using (TransactionScope ts = new TransactionScope())
{
using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope())
{
// update table 1
// update table 2
// ts.commit here
}
}
- Is MS-DTC a default service on Windows systems(XP, Vista, Windows 7, Servers etc)?
- If it is not enabled, how can I make sure it gets enabled during the installation process of my application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
MSDTC 应该随 Windows 一起安装。如果不是,可以使用以下命令进行安装:
您可以使用 sc.exe 配置 MSDTC 服务。将服务设置为自动启动并启动服务:
请注意,您将需要管理员权限才能执行上述操作。
MSDTC should come installed with windows. If it's not it can be installed with the following command:
You can configure the MSDTC service using sc.exe. Set the service to start automatically and start the service:
Note you will need administrator privilege to perform the above.
我用:
I use:
这可能会有所帮助:
http://www.thereforesystems.com/turn-on -msdtc-windows-7/
This might be helpful:
http://www.thereforesystems.com/turn-on-msdtc-windows-7/
如果您的 DBMS 是 SQL Server 2000 并且您使用 TransactionScope,则即使是本地事务也会创建分布式事务。然而,SQL Server 2005(可能还有 SQL Server 2008)足够聪明,可以发现不需要分布式事务。我不知道这是否仅适用于本地数据库,或者如果您的事务仅涉及单个数据库(即使它位于删除服务器上),那么情况是否如此。 http://davidhayden.com/blog/dave/archive/2005 /12/09/2615.aspx
一个提示,你可以使用批量查询来避免TransactionScope。
http://subsonicproject.com/docs/BatchQuery
BatchQuery、QueueForTransaction 和 ExecuteTransaction 将不会使用 TransactionScope(当然这取决于提供程序的实现),但选择底层数据提供程序的事务机制(在本例中为 SqlTransaction),这不需要 MSTDC。
If your DBMS is SQL Server 2000 and you use a TransactionScope a distributed transaction is created even for local Transaction. However SQL Server 2005 (and probably SQL Server 2008) are smart enough to figure out that a distributed Transaction is not needed. I don't know if that only applies to local DB's or even is true if you Transaction only involves a single DB even if it's on a remove server. http://davidhayden.com/blog/dave/archive/2005/12/09/2615.aspx
One hint, you can use a batch query to avoid the TransactionScope.
http://subsonicproject.com/docs/BatchQuery
BatchQuery, QueueForTransaction and ExecuteTransaction will not use a TransactionScope (of course that depends on the provider implementation) but choose the transaction mechanismn of the underlying data provider (SqlTransaction in this case) which won't require MSTDC.