一个事务:顺序如下:
1.本地插入修改数据到本地数据库
2.将插入修改的数据上传到远程数据库
3.写系统日志及打印相关信息。1.2.3步的任何一步出错,事务将回滚。
另,因为局域网及远程访问的网络不能保证通畅,经常会出现断网,掉线等现象。
----------------
希望高手们能给个例子出来。谢谢大家。

解决方案 »

  1.   

    没写过这样的,
    不过你通过raise error后,就回滚,应该是可以的。
      

  2.   

    分布式事务,开启msdtc  效率不好
      

  3.   

    我感觉也应该在程序中实现,问题是我太菜了,编程到现在几乎已经忘干净了,唯一记得的估计只有 hello word了,哈哈
      

  4.   


    If you don't need the printing to be part of a transaction, then enclosing the entire operation in a distributed transaction will ensure that you can rollback after encountering error.However, if you need to make printing part of the transaction, you need to research to find a printer drive that supports MSDTC. That might be one available.You might want to look at your problem from another perspective - you can potentially poll records that require printing and set those that are not printed to be printed, rather than attempting to include printing as part of a transaction.
      

  5.   

    启动分布式事务 BEGIN DISTRIBUTED TRANSACTION示例
    本例在本地和远程数据库上更新作者的姓。本地和远程数据库将同时提交或同时回滚本事务。 说明  除非正在运行 Microsoft® SQL Server™ 的计算机上当前装有 MS DTC,否则本例会产生错误信息。关于安装 MS DTC 的更多信息,请参见 Microsoft 分布式事务处理协调器文档。
    USE pubs
    GO
    BEGIN DISTRIBUTED TRANSACTION
    UPDATE authors
       SET au_lname = 'McDonald' WHERE au_id = '409-56-7008'
    EXECUTE remote.pubs.dbo.changeauth_lname '409-56-7008','McDonald'
    COMMIT TRAN
    GO