Stored procedure print message
How do i show Print message of a stored procedure in front end.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Oct 24, 2009, 4:04 AM EDT
Friend,
The printed output can be processed in the SqlConnection event InfoMessage:
So if you have to display the result of PRINT statements in an TextBox,
SqlConnection cn = OpenMyConnection(); cn.InfoMessage += new SqlInfoMessageEventHandler(cn_InfoMessage); sbLog = new System.Text.StringBuilder(); SqlCommand cmd = new SqlCommand("PRINT 'Hello World'", cn); cmd.ExecuteNonQuery(); TextBox1.Text = sbLog.ToString(); void cn_InfoMessage(object sender, SqlInfoMessageEventArgs e) { sbLog.AppendLine(e.Message); }