SqlConnection conn = Infcon.create(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "UpdateNoticeMx"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter parm1 = new SqlParameter("@mxid", SqlDbType.Int, 4); parm1.Value = Convert.ToInt32(mxid); parm1.Direction = ParameterDirection.Input; cmd.Parameters.Add(parm1); SqlParameter parm2 = new SqlParameter("@type", SqlDbType.Int, 4); parm2.Value = type; parm2.Direction = ParameterDirection.Input; cmd.Parameters.Add(parm2); SqlParameter parm3 = new SqlParameter("@nmid", SqlDbType.Int, 4); parm3.Direction = ParameterDirection.Output;//output cmd.Parameters.Add(parm3); conn.Open(); cmd.ExecuteNonQuery(); //执行存储过程 int nmid = Convert.ToInt32(parm3.Value);//获取parm3的值,即存储过程返回值 conn.Close(); conn.Dispose();