多服务器实现分布式事务功能!
安装DTC组件,设置MSDTC,注意:双方都要启动MSDTC服务,MSDTC服务依赖于RPC(Remote Procedure Call (RPC))服务,RPC使用135端口,保证RPC服务启动,如果服务器有防火墙,保证135端口不被防火墙挡住;保证链接服务器中语句没有访问发起事务服务器的操作。
采用WEB的TransactionScope(事务块)方式,实例代码如下:
public void GotoTransactionScope()
{
//创建事务块
using (TransactionScope TransScope = new TransactionScope())
{
try
{
int intResult = 0;
//服务器1操作
intResult = GoServerOne();
..........................