忘了,加上 return IF 出错 BEGIN RAISERROR ('错误信息', 16, 1) ROLLBACK TRANSACTION return 16 END
Private Sub ErrorLog() . . . Dim errLoop As ADODB.Error . . . ' Loop through each Error object in Errors collection. For Each errLoop In cn.Errors Dim strError(5) Dim i As Integer
' Loop through the five specified properties of Error object. i = 0 Do While i < 5 Form2.lstErrors.AddItem strError(i) i = i + 1 Loop
Form2.lstErrors.AddItem ""
Next
' Create string for summary count of errors. c = cn.Errors.Count & " provider error(s) occurred."
' Display a count of the provider errors. Form2.lstErrors.AddItem c Form2.lstErrors.AddItem ""' Clear the Errors collection. cn.Errors.Clear
Private Sub ErrorLog() . . . Dim errLoop As ADODB.Error . . . ' Loop through each Error object in Errors collection. For Each errLoop In cn.Errors Dim strError(5) Dim i As Integer
IF 出错
BEGIN
RAISERROR ('错误信息', 16, 1)
ROLLBACK TRANSACTION
return 16
END
. . .
Dim errLoop As ADODB.Error
. . .
' Loop through each Error object in Errors collection.
For Each errLoop In cn.Errors Dim strError(5)
Dim i As Integer
strError(0) = "Error Number: " & errLoop.Number
strError(1) = " Description: " & errLoop.Description
strError(2) = " Source: " & errLoop.Source
strError(3) = " SQL State: " & errLoop.SQLState
strError(4) = " Native Error: " & errLoop.NativeError
' Loop through the five specified properties of Error object.
i = 0
Do While i < 5
Form2.lstErrors.AddItem strError(i)
i = i + 1
Loop
Form2.lstErrors.AddItem ""
Next
' Create string for summary count of errors.
c = cn.Errors.Count & " provider error(s) occurred."
' Display a count of the provider errors.
Form2.lstErrors.AddItem c
Form2.lstErrors.AddItem ""' Clear the Errors collection.
cn.Errors.Clear
. . .
Dim errLoop As ADODB.Error
. . .
' Loop through each Error object in Errors collection.
For Each errLoop In cn.Errors Dim strError(5)
Dim i As Integer
strError(0) = "Error Number: " & errLoop.Number
strError(1) = " Description: " & errLoop.Description
strError(2) = " Source: " & errLoop.Source
strError(3) = " SQL State: " & errLoop.SQLState
strError(4) = " Native Error: " & errLoop.NativeError
' Loop through the five specified properties of Error object.
i = 0
Do While i < 5
Form2.lstErrors.AddItem strError(i)
i = i + 1
Loop
Form2.lstErrors.AddItem ""
Next
' Create string for summary count of errors.
c = cn.Errors.Count & " provider error(s) occurred."
' Display a count of the provider errors.
Form2.lstErrors.AddItem c
Form2.lstErrors.AddItem ""' Clear the Errors collection.
cn.Errors.Clear