多台数据服务器多个数据库如何开展事务?

大健 2002-11-15 12:10:46
我的一次更新操作需要同时对两台服务器的多个数据库里的多个表进行UPDATE,基于数据完整性的考虑,我想用事务。
请问asp.net里如何对多台服务器的多个库的多个表进行事务操作?
...全文
36 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
大健 2002-12-03
  • 打赏
  • 举报
回复
看来短时间内都没空去跟进这事,结贴算了
大健 2002-11-19
  • 打赏
  • 举报
回复
如果是同一台服务器的多个库,打开一个连接,换库时用MyConnection.ChangeDatabase("AnotherDabaBase")就可以多个库做事务了,但多台服务器就没办法。
大侠们提供的资料还没时间去看:(好像很难似的)
这问题先呆着,过几天再来:)
ProcessDB 2002-11-18
  • 打赏
  • 举报
回复
http://www.htmchina.com/37/04/00075076,9.htm
我的代码如下:生成DLL
using System;
using System.IO;
using System.Data;
using System.Data.OleDb;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.Reflection;

namespace Canon.wwg.wwgB.batch
{

[Transaction(TransactionOption.Required)]
public class DBOperation:ServicedComponent
{

private OleDbConnection myConnection;
private OleDbCommand myCommand;

/// <summary>
/// connect database
/// </summary>
/// <param name=”connection”>database config infomation
/// formatting : datasource=..;user id=..;password=...
/// </param>
/// <returns></returns>
public void Connect(string connection)
{

myConnection = new OleDbConnection( connection );
myConnection.Open();

myCommand = new OleDbCommand();
myCommand.Connection = myConnection;

return;
}

/// <summary>
/// Execute one insert statement and insert one record into the table
/// </summary>
/// <param name=”connection”>database config infomation
/// formatting : datasource=..;user id=..;password=...
/// </param>
/// <returns></returns>

public int CommandExcute(string commandstring)
{

int returnValue = 0;

myCommand.CommandText = commandstring;
returnValue = myCommand.ExecuteNonQuery();

return returnValue;

}

/// <summary>
/// Commit the com+ transaction
/// </summary>

public void Commit()
{

ContextUtil.SetComplete();

if(myConnection!=null)
myConnection.Close();

}

/// <summary>
/// Roolback the com+ transaction
/// </summary>

public void Abort()
{

ContextUtil.SetAbort();

if(myConnection!=null)
myConnection.Close();

}

}
}
在主文件中调用即可,注意要添加一个using System.EnterpriseServices;
saucer 2002-11-18
  • 打赏
  • 举报
回复
ADO.NET does not support distributed transactions involving multiple resource managers, you need to use DTC API, see
Distributed Transactions Overview
http://msdn.microsoft.com/library/en-us/cossdk/htm/pgdtc_dev_3lrn.asp?frame=true
saucer 2002-11-15
  • 打赏
  • 举报
回复
this topic is kind of big, but you need to use DTC (Distributed Transaction Coordinator), read some basics:

transactional programming with .net
http://www.develop.com/summercamp/conferencedotnet/materials/X8.pdf
henryfan1 2002-11-15
  • 打赏
  • 举报
回复
com+
icyer 2002-11-15
  • 打赏
  • 举报
回复
用多个连接,最后一起提交
mmkk 2002-11-15
  • 打赏
  • 举报
回复
刚好有一本WROX的新书是关于ASP.NET和分布式数据库方面的,不妨买来看看~
angel_lee 2002-11-15
  • 打赏
  • 举报
回复
gz
大健 2002-11-15
  • 打赏
  • 举报
回复
呜呜。。。没收获
有例子看吗?
「已注销」 2002-11-15
  • 打赏
  • 举报
回复
使用COM+来完成多数据库的事务处理

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧