September 21, 2005 at 11:43 pm
Hi, im a noob to sqlServer and i need some help with the PRINT command. Lets say that i neeed a progress bar for a procedure which takes a while to execute. The only way i thought of doing it is by PRINT ing the progres something like 1,2,3,4....
But my program doesnt catch those messages. I've read in help that sql server 7 sends them as informational messages but i dont catch them. I use Delphi7 as IDE and Ado components for Database jobs.
I need a way to get the messages from the print ... or just get the progress some other way.
September 23, 2005 at 3:37 am
I'm not a Delphi programmer, but you should be able to use the ADO Connection's Error collection to catch your messages.
In VB you could use the following routine, which I’m sure you could modify to run asynchronously:
' Loop through the recordsets displaying any messages, and getting the error code and request if if available
Do While Not rsRequest Is Nothing
Select Case rsRequest.State
Case 0 ' adStateClosed
If objConn.Errors.Count > 0 Then
For Each adoErr In objConn.Errors
' Display messages/errors
Debug.Print adoErr.Description
Next
End If
Set rsRequest = rsRequest.NextRecordset
Case 1 ' adStateOpen
If Not rsRequest.EOF Then
' Get the Field Data
For Each adoField In rsRequest.Fields
Debug.Print adoField.Name & "=" & adoField.Value
Next
End If
Set rsRequest = rsRequest.NextRecordset
Case Else ' adStateConnecting, adStateExecuting, adStateFetching
' Wait
DoEvents
End Select
Loop
September 27, 2005 at 12:36 pm
thank you for the post, but the problem is that if i raiserror smaller then 16 , i dont get any error (just an informative message), if i make it a 16 i will get a nasty error on my screen but i think i can catch it, and also my stored procedure will stop working. ...
will just return ...
September 28, 2005 at 2:17 am
This routine should work with messages created by PRINT statements, so you don't need to RAISERROR(). It's just that in ADO it is confusingly named the Errors collection.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply