Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Receiving values from 'Raiseerror' and 'Print'
Message
De
25/01/2001 11:26:48
Greg Coopman
Gc Systems Corporation
Hollywood, Floride, États-Unis
 
 
À
24/01/2001 17:23:09
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00306407
Message ID:
00468510
Vues:
21
After writing some code myself, it worked. The note below is part of the team communications I wrote to communicate my results to my colleagues.

I have written VB Code that appears to get a Valid Errors.Count Value corresponding to the number of errors that arise in the stored procedures RaiseError commands and that have severities below 11. Why this code appears to work and the code we were trying yesterday did not, -- I don't know. You can test the code, I have changed the test procedure to AdminTestGreg_sp rather than the public procedure DeleteMatrix_sp. It worked both using ADO 2.5 and ADO 2.6 in this tests.


SQL Code:
----------
CREATE PROCEDURE AdminTestGreg_sp
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', 8, 2) WITH LOG, SETERROR
RAISERROR( 'AL03This is a test3', 7, 3) WITH LOG, SETERROR
RAISERROR( 'AL03This is a test4', 6, 1) WITH LOG, SETERROR



VB Code:
---------
Dim oError As ADODB.Error

Private Sub Command1_Click()

Call CreateParms

End Sub
Sub CreateParms()

Dim ADOCmd As New ADODB.Command
Dim ADOPrm As New ADODB.Parameter
Dim ADOCon As ADODB.Connection
Dim ADORs As ADODB.Recordset
Dim sParmName As String
Dim strConnect As String
Dim rStr As String
On Error GoTo ErrHandler

strConnect = "driver={SQL Server};server=MIASD1;uid=sa;pwd=;database=dbpdr"

Set ADOCon = New ADODB.Connection
With ADOCon
.Provider = "MSDASQL"
.CursorLocation = adUseServer 'Must use Server side cursor.
.ConnectionString = strConnect
.Open
End With

Set ADOCmd.ActiveConnection = ADOCon
With ADOCmd
.CommandType = adCmdStoredProc
.CommandText = "AdminTestGreg_sp"
End With

Set ADORs = ADOCmd.Execute

Debug.Print "Errors.Count = " & ADOCon.Errors.Count

For Each oError In ADOCon.Errors
Debug.Print oError.Description
Next oError


GoTo Shutdown

ErrHandler:
Call ErrHandler(ADOCon)
Resume Next

Shutdown:
Set ADOCmd = Nothing
Set ADOPrm = Nothing
Set ADORs = Nothing
Set ADOCon = Nothing

End Sub

Sub ErrHandler(objCon As Object)


End Sub
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform