public XianModel Postxian(FenModel model) { SqlCommand com = conn.CreateCommand(); //类型 com.CommandType = CommandType.StoredProcedure; //存储过程名称 com.CommandText = "xian"; //存储过程中的条件 //总条数要注意是输出参数 SqlParameter[] sqls = new SqlParameter[] { new SqlParameter{ParameterName="ye",SqlDbType=SqlDbType.Int,SqlValue=model.ye }, new SqlParameter{ParameterName="tiao",SqlDbType=SqlDbType.Int,SqlValue=model.tiao }, new SqlParameter{ParameterName="zong",SqlDbType=SqlDbType.Int,Direction=ParameterDirection.Output } }; //添加进去 com.Parameters.AddRange(sqls); //实例化适配器 SqlDataAdapter sda = new SqlDataAdapter(com); DataTable dt = new DataTable(); sda.Fill(dt); //找出总条数 int zong = Convert.ToInt32(com.Parameters["zong"].Value); //进行实例化 XianModel xian = new XianModel { dt = dt, zong = zong }; return xian; }