April 21, 2010 at 4:03 pm
Hi there,
For various reasons, I need to build a small Query Analyser kind of tool in .Net and everything works fine but I'd like to add a little twist to show the PRINT statements executed within my stored procs.
A bit like in SSMS, I'd have one tab showing the resultset while I'd like to show the potential Debug/Print statements in another tab.
I know I can fetch all PRINT statements through the Errors collection of a SqlException raised but only errors raised at a certain level generate exceptions... and I don't really want exceptions raised if everything is fine anyway.
Question: is there a way to collect all print statements and minor errors without going through the SqlException class?
Many Thanks
Eric :unsure:
April 21, 2010 at 5:26 pm
yes you can Eric; i did the same thing making a SSMS clone in .NET, for me it was just for fun, but you learn all the pieces you need.
What you are looking for is SQLConnection.InfoMessage
all the print statements, as well as stuf like rows affected and stuff appear there.
googling for ".net sql print statements InfoMessage event in SqlConnection" gets you other code examples as well.
Lowell
April 22, 2010 at 7:01 am
Brilliant!
Many thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply