Stored Procedures: Returning DataBy Bill Graziano on 09 April 2001This article discusses three common ways to return data from stored procedures: ret......
(SqlConnection conn = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand("dbo.TestReturn"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@Invalue", 3));
SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
returnValue.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(returnValue);
conn.Open();
cmd.Connection = conn;
cmd.ExecuteNonQuery();
int count = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
Response.Write("<p>Return Code: " count.ToString());
conn.Close();
}
}
Those are the three best ways I know of to get data back from a stored procedure. Enjoy!
6/6 首页 上一页 4 5 6 |