public string CountOut(int month)
{
comm = new SqlCommand("pCountMonthO",conn);
comm.CommandType = CommandType.StoredProcedure; SqlParameter m = new SqlParameter("@month",SqlDbType.Int);
m.Value = month;
comm.Parameters.Add(m); SqlParameter c = new SqlParameter("@count",SqlDbType.Money);
c.Direction = ParameterDirection.Output;
comm.Parameters.Add(c); try
{
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
string d = c.Value.ToString();
return d;
}
catch(SqlException ex)
{
errMsg = ex.Message;
return "err";
}
}看看就懂了。
{
comm = new SqlCommand("pCountMonthO",conn);
comm.CommandType = CommandType.StoredProcedure; SqlParameter m = new SqlParameter("@month",SqlDbType.Int);
m.Value = month;
comm.Parameters.Add(m); SqlParameter c = new SqlParameter("@count",SqlDbType.Money);
c.Direction = ParameterDirection.Output;
comm.Parameters.Add(c); try
{
conn.Open();
comm.ExecuteNonQuery();
conn.Close();
string d = c.Value.ToString();
return d;
}
catch(SqlException ex)
{
errMsg = ex.Message;
return "err";
}
}看看就懂了。
sampParm.Direction = ParameterDirection.ReturnValue;
cmd.ExecuteNonQuery();
int 你想要的=(int)cmd.Parameters["ReturnValue"].Value;