Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net SQLConnection没有';无法实现IEnlistmentNotification_.net_Sql_Vb.net_Ado.net_Transactions - Fatal编程技术网

.net SQLConnection没有';无法实现IEnlistmentNotification

.net SQLConnection没有';无法实现IEnlistmentNotification,.net,sql,vb.net,ado.net,transactions,.net,Sql,Vb.net,Ado.net,Transactions,我试图理解如何确保只有在提交事务时才将日志条目输入到文件系统中。请参阅下面的代码 Using (scope As TransactionScope = new TransactionScope()) 'write log log file (line 2)' scope.complete End Using 在事务作用域完成之前写入日志文件的那一刻 我已经阅读了有关IEnlistmentNotification界面的信息。我知道SQLConnection类允许事务和分布式事

我试图理解如何确保只有在提交事务时才将日志条目输入到文件系统中。请参阅下面的代码

Using (scope As TransactionScope = new TransactionScope()) 
    'write log log file (line 2)'
    scope.complete 
End Using
在事务作用域完成之前写入日志文件的那一刻


我已经阅读了有关
IEnlistmentNotification
界面的信息。我知道
SQLConnection
类允许事务和分布式事务。因此,我希望这个类实现
IEnlistmentNotification
,但它没有。为什么不呢?

IEnlistmentNotification
被资源管理器用于参与事务,但它不是由SQL连接或事务实现的

如果您实现自己的事务性资源管理器,您将实现该接口,并使用
登记持久性
登记易失性
通知系统您希望参与此事务。从这一点开始,您将收到对接口的调用,该接口允许您对事务的状态做出反应并对其产生影响


如果您想以事务方式修改文件,您必须为此实现或找到一个资源管理器。此资源管理器将实施
IEnlistmentNotification
,并通过上述登记方法参与事务。

谢谢+1.是否有实现此接口的类的示例?这是MSDN()中的相关主题,这是MSDN杂志中的一篇介绍易失性资源管理器()的文章。您对
IEnlistmentNotification
SQL连接使用的替代方案有何见解?显然有一些代码可以处理所有这些。