发布网友 发布时间:2022-04-29 23:49
共1个回答
热心网友 时间:2022-04-13 13:25
1、执行命令行: net start msdtc 。
检查服务Distributed Transaction Coordinator是否开启,同时在此服务上右键属性->依存关系 检查依存的服务是否开启。
2、开始->管理->组件服务->我的电脑->右键属性 各选项卡的设置
3、设置NetBIOS
4、在防火墙中允许135端口
5、在任务管理器中查看mstsc的PID,在cmd命令行中键入netstat.exe -aon 根据PID找到端口号,并把此端口加入防火墙允许中。
6、如下代码执行成功:
using (TransactionScope ts = new TransactionScope())
{
ConfigureHandler ch1 = new ConfigureHandler(Config);
DomSqlMapBuilder mapperbuilder1 = new DomSqlMapBuilder();
ISqlMapper mapper3 = mapperbuilder1.ConfigureAndWatch(ch1);
mapper3.DataSource = new IBatisNet.Common.DataSource();
mapper3.DataSource.ConnectionString = "server=192.168.1.58;database=XXX;uid=XXX;pwd=XXX";
mapper3.DataSource.DbProvider = mapper.DataSource.DbProvider;
mapper3.DataSource.Name = "exam3";
mapper3.OpenConnection();
mapper3.Delete("delbyid3", "6");
mapper3.CloseConnection();
ConfigureHandler ch = new ConfigureHandler(Config);
DomSqlMapBuilder mapperbuilder = new DomSqlMapBuilder();
ISqlMapper mapper2 = mapperbuilder.ConfigureAndWatch(ch);
mapper2.DataSource = new IBatisNet.Common.DataSource();
mapper2.DataSource.ConnectionString = "server=192.168.1.28;database=XXXX;uid=XXX;pwd=XXX;";
mapper2.DataSource.DbProvider = mapper.DataSource.DbProvider;
mapper2.DataSource.Name = "exam";
mapper2.OpenConnection();
mapper2.Delete("delbyid", "4");
mapper2.CloseConnection();
ts.Complete();
}
注:以上环境配置可能有些不是必要的,但是时间有限,就没有一一去掉后测试,仅作后来者参考。