msdn的错误?

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatasqlclientsqltransactionclassrollbacktopic1.asp?frame=true
上面这个连接是msdn中关于SqlTransaction.Rollback方法的使用说明
在关于Exceptions的介绍中指出SqlTransaction会抛出一下异常

Exception 尝试提交事务时出错。

InvalidOperationException 事务已提交或回滚。连接已断开。

但是在后面的例子中,他并没有捕获以上异常

 catch(Exception e)
    {
      try
      {
        myTrans.Rollback();
      }
      catch (SqlException ex)
      {
        if (myTrans.Connection != null)
        {
          Console.WriteLine("An exception of type " + ex.GetType() +
                            " was encountered while attempting to roll back the transaction.");
        }
      }
   
      Console.WriteLine("An exception of type " + e.GetType() +
                        " was encountered while inserting the data.");
      Console.WriteLine("Neither record was written to database.");
    }

这是msdn的错误吗?如果不是为何在Rollback的时候只捕获SqlException呢?例子也不能误导吧。



 

 


 

 

posted on 2004-03-19 13:11  coollzh  阅读(768)  评论(2编辑  收藏  举报

导航