存储过程
CREATE PROCEDURE [dbo].[m_products_Insert]
(@prodtid INT = 0
)
AS
DECLARE @returnValue VARCHAR(18) -- 返回操作结果
SET @returnValue = -1
RETURN @returnValue
代码接收
public static String ExeStore(string storeName, Dictionary<string, object> paraNameValue)
{
SqlConnection con = new SqlConnection(ConString);
SqlCommand com = new SqlCommand();
com.CommandType = CommandType.StoredProcedure;
com.CommandText = storeName;
AssignParameter(com, paraNameValue);
SqlParameter pret = new SqlParameter();
pret.Direction = ParameterDirection.ReturnValue;
com.Parameters.Add(pret);
com.Connection = con;
try
{
com.Connection.Open();
com.ExecuteNonQuery();
return pret.Value.ToString();
}
catch (Exception e)
{
throw new ArgumentException(e.Message);
}
finally
{
com.Connection.Close();
}
}
标红色的部分就是针对接收返回值,所要增加的代码