How to retrieve the RETURN value from a stored procedure in .NET
Wednesday, November 21, 2007(Pretend you have an open SqlConnection called "conn".)
SqlCommand sqlCommand = new SqlCommand("webmail_getMessageCount");
sqlCommand.Connection = conn;
sqlCommand.CommandType = CommandType.StoredProcedure;
SqlParameter messageCount = new SqlParameter("@count", SqlDbType.Int);
messageCount.Direction = ParameterDirection.ReturnValue;
sqlCommand.Parameters.Add(messageCount);
sqlCommand.ExecuteNonQuery();
return (int)messageCount.Value;
Labels: ASP.NET, SQL Server - Scripts







