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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -