請把你的On Error Goto 去掉﹐然后把 if Con.Errors.Count >0 then
改成 If Con.Errors.Count >0 and Err.Number <>0 then  因為有時候CommitTrans會不是返回Connection的Error而是返回Vb的Error.

解决方案 »

  1.   

    改了也没有用,网络中断时,commitTrans根本就不报错。
      

  2.   

    改了也没有用,网络中断时,commitTrans根本就不报错。
    就算是返回Vb的Error,运行结果也应该是"Please write to local database!"
    而不应该是“Trans Successful”啊。
      

  3.   

    改为以下代码测试一下:
    flag=true
    con.Errors.Clear
    On Error GoTo LocalDB
    con.BeginTrans
    con.Execute "delete from userinfo"
    con.CommitTrans
    If con.Errors.Count > 0 Then
    flag = False
    End If
    If flag Then
    MsgBox "Trans Successful!"
    Else
    MsgBox "Trans Failed!"
    End If
    Exit Sub
    LocalDB:
        MsgBox "Please write to local database!"
        con.RollbackTrans
        Exit Sub
      

  4.   

    to Tsou:
       没有用,如果执行到commitTrans网络中断的话,根本就不报错,也就不会执行到LocalDB这一行。