c# - Getting print messages from stored procedure along with rows affected in correct order -
i want print
result along current number of rows affected particular query in stored procedure.
currently, using statementcompleted
property output.
insert sprocparam values(@sprocid, @paramname, @paramtype, @isnullable, @description); print 'this test output' select * sprocparam;
my c# code goes this:
.... sqlconnection conn = new sqlconnection(connectionstring); conn.open(); conn.infomessage += new sqlinfomessageeventhandler(myconnection_infomessage); command.statementcompleted += sqlcommand_statementcompleted; command.executescalar(); ..... static void sqlcommand_statementcompleted(object sender, statementcompletedeventargs e) { sproccontroller.executionmessage += e.recordcount + " row(s) affected \n"; } void myconnection_infomessage(object sender, sqlinfomessageeventargs e) { sproccontroller.executionmessage += e.message; }
now answer each query separately. want answer this:
(1 row(s) affected) test output (21 row(s) affected)
i not able retrieve these print messages in natural order coded in stored procedure.
output getting :
(1 row(s) affected) (21 row(s) affected) test output
the stored procedure can't changed. can change c# code.
please help!
you need subscribe infomessage
event on sqlconnection
object receive messages print
statements.
Comments
Post a Comment