- Simple stored procedures are as follows: ------------------------------------------- -------------------------------------------- Create Proc P_Test @ Name VARCHAR (20), @ Rowcount Int outputasbegin select * from t_customer where name = @@ rowcountendgo ------------------------- -------------------------------------------------- -------------- store procedure calls are as follows: ------------------------------ -------------------------------------------------- -------- Declare @i intexec p_test 'a', @ i outputselect @ i - Result / * Name Address Tel ------------------ -------------------- A Address Telphone
(The number of rows affects is 1 line)
----------- 1
(The number of rows affects is 1 line) * / -------------------------------------- -------------------------------------------------- - DOTNET section (C #) - WebConfig file: -------------------------------------- -------------------------------------------------- ...
// add output parameters myCommand.Parameters.Add ( "@ Rowcount", SqlDbType.Int); myCommand.Parameters [ "@ Rowcount"] Direction = ParameterDirection.Output;. MyCommand.ExecuteNonQuery (); DataAdapter.SelectCommand = myCommand;
IF (MyDataSet! = null) {dataadapter.fill (MyDataSet, "Table");} DataGrid1.datasource = MyDataSet; DataGrid1.database (); // Get stored procedure output parameter label1.text = mycommand.Parameters [@ rowcount "] .Value.toString ();
IF (MyConnection.State == ConnectionState.Open) {myconnection.close ();}
} ------------------------------------- -------------------------------------- Run the above code (return to record collection and storage Procedure return value)