Feedback from stored procedure

S

Stephan Zaubzer

Is there a possibility to get some feedback in ado.net when a stored
procedure runs?
In the sqlserver query analyzer for example all messages which are
printed by a stored procedure (print statement in the sp) are shown in
the messges tab of the output window during runtime of the stored
procedure.
When I add a print statement in my SP how does ado.net handle this and
is it possible to get the messages during runtime?
Regards
Stephan
 
W

William \(Bill\) Vaughn

Trap the Connection object's InfoMessage event.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
S

Stephan Zaubzer

When I use Execute Reader, my code will probably block for some seconds,
if a large procedure is executed. Will the InfoMessage event occur in a
separate thread? Or do I need to run the command in a separate thread?
Regards
Stephan
 
W

William \(Bill\) Vaughn

In ADO.NET 2.0 you can execute queries asynchronously, but that won't return
a single row--or the InfoMessage events. These are passed back in the TDS
stream at the end (or very near there-to)--not as they are encountered in
the SP.

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
T

Thomas Weingartner

Hi Stephan

I did some research about your problem, and I found that the InfoMessage event will be raised in your thread while you are in ExecuteReader method. But this is only true, if you use

RAISERROR ('message from raiserror', 10, 1) WITH NOWAIT

from the stored procedure. This works even for a CLR written SP.

Hope that helps
Greetings from Switzerland
Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top