Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
My stored procedure contains several RaiseErrors to return Warning information to the VB Client via ADO with severity levels 1 - 15. The problem is that the ADO Errors Collection that is received back only identifies the first RaiseError and none of the others. The Errors.Count on VB is always 1 no matter how many RaiseErrors I put in the code and I also know the commands after the RaiseErrors are continuing to execute.
--------------
SQL Code:
--------------
CREATE PROCEDURE DeleteMatrix_sp
@MatrixID UNIQUEIDENTIFIER
AS
DELETE Testgc_tbl
INSERT Testgc_tbl
(testfield)
VALUES ('Greg')
RAISERROR( 'AL03This is a test', 9, 1) WITH LOG, SETERROR
RAISERROR( 'AL03This is a test2', 11, 2) WITH LOG, SETERROR
RAISERROR( 'AL03This is a test3', 12, 3) WITH LOG, SETERROR
RAISERROR( 'AL03This is a test4', 10, 1) WITH LOG, SETERROR
DELETE FROM MatrixUser_Tbl
WHERE [MatrixID] = @MatrixID
EXEC LogDebug_sp
'Delete from Matrix_Tbl'
DELETE FROM Matrix_Tbl
WHERE [ID] = @MatrixID
-------------
VB code:
--------------
Private Function ProcessErrors(oConn As ADODB.Connection, _
ByVal Source As String, _
ByVal Category As String) As Boolean
Dim oError As ADODB.Error
Dim sPrefix As String
Dim lLogVal As Integer
moLog.WriteLogEntry 0, crLogDebugOut, "UniDAL.CDataAccess", "ProcessErrors", "Errors.Count = " & oConn.Errors.Count
For Each oError In oConn.Errors
sPrefix = Left$(oError.Description, 4)
If Left$(sPrefix, 2) = "AL" Then
lLogVal = CInt(Right$(sPrefix, 2))
moLog.WriteLogEntry oError.NativeError, lLogVal, Source, Category, Right$(oError.Description, Len(oError.Description) - 4)
Else
' error found
ProcessErrors = True
moLog.WriteLogEntry 54321, crLogError, Source, Category, oError.Description
End If
Next oError
End Function
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement