Public static void querylist () {sqlconnection con = new sqlconnection ("database connection string"); sqlcommand cmd = new sqlcommand ("Stored Procedure name", con ); // specify the command type cmd. commandtype = commandtype. storedprocedure; sqlparameter [] para = {New sqlparameter ("parameter 1", sqldbtype. INT), new sqlparameter ("parameter 2", sqldbtype. INT), new sqlparameter ("parameter 3", sqldbtype. INT), new sqlparameter ("parameter 4", sqldbtype. INT)}; Para [0]. value = 3; Para [1]. value = 4; Para [2]. direction = parameterdirection. output; // set the output direction of the parameter. Para [3]. direction = parameterdirection. output; cmd. parameters. addrange (para); // Add the parameter to the command object sqldataadapter adapter = new sqldataadapter (CMD); datatable dt = new datatable (); adapter. fill (DT); foreach (datarow DR in DT. rows) {console. writeline (Dr [0]. tostring ();} int pagecount = convert. toint32 (CMD. parameters [2]. value); int rowcount = convert. toint32 (CMD. parameters [3]. value); console. writeline ("pagecount =" + pagecount + ", rowcount =" + rowcount );}