Retrieving SQL output

G

Guest

Using ADO.NET from ASP.NET. Have a SqlConnection executing stuff (stored procedures)

I would like to be able to retrieve informational messages from the SQL sps, which comment on what they are doing (updating tables etc.), and show them to the user/write them to a file. Is there any way I can get at anything that comes from a SQL PRINT statement in this context? osql utility lets this go to standard output, which can be captured; that's the sort of thing I have in mind, but I suspect it may go into the blue nowhere from ADO.NET. Or is my best/only solution to rewrite messages via RAISERROR <severity-level-less-than-10>, and catch in code via InfoMessage event + InfoMessageEventArgs

And if there is a better ng than here to post this, please let me know...
 
S

Scott Allen

Informational messages include PRINT and RAISEERROR (severity < 11)
statements - they won't just go into the blue nowhere but show up in
the InfoMessage event handler.

Just be aware that the events won't start firing until after the batch
has completed.
 
K

Kevin Spencer

Any information you want from the Stored Procedure can be returned as an
output parameter.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

jb said:
Using ADO.NET from ASP.NET. Have a SqlConnection executing stuff (stored procedures).

I would like to be able to retrieve informational messages from the SQL
sps, which comment on what they are doing (updating tables etc.), and show
them to the user/write them to a file. Is there any way I can get at
anything that comes from a SQL PRINT statement in this context? osql
utility lets this go to standard output, which can be captured; that's the
sort of thing I have in mind, but I suspect it may go into the blue nowhere
from ADO.NET. Or is my best/only solution to rewrite messages via RAISERROR
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top