/// <summary> /// 分页导航获取总页数 /// </summary> /// <param name="strwhere">查询条件</param> /// <param name="tblName">表、视图</param> /// <returns>Total:字段名(总的记录数)</returns> public static DataTable GetDataTable(string strwhere, string tblName) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@strwhere", strwhere), //查询条件(注意: 不要加where) new SqlParameter("@tblName", tblName), //表名 new SqlParameter("@doCount", 1) //返回记录总数,非 0 值则返回 }; return(SqlHelper2.ExecuteTable(CommandType.StoredProcedure, "SP_Pagination", param)); }
/// <summary> /// 分页数据库操作函数 /// </summary> /// <param name="strwhere">查询条件(注意: 不要加where)</param> /// <param name="tblName">表名</param> /// <param name="OrderType">设置排序类别,非 0 值则降序</param> /// <param name="fldName">排序的字段名</param> /// <param name="strGetFields">需要返回的列</param> /// <param name="PageSize">页尺寸</param> /// <param name="PageIndex">页码</param> /// <param name="doCount">,[0:返回查询的表数据,非0:值则返回记录总数]</param> /// <returns>返回一个表</returns> public static DataTable GetDataTable(string strwhere, string tblName, int OrderType, string fldName, string strGetFields, int PageSize, int PageIndex, int doCount) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@strwhere", strwhere), //查询条件(注意: 不要加where) new SqlParameter("@tblName", tblName), //表名 new SqlParameter("@OrderType", OrderType), //设置排序类别,非 0 值则降序 new SqlParameter("@fldName", fldName), //排序的字段名 new SqlParameter("@strGetFields", strGetFields), //需要返回的列 new SqlParameter("@PageSize", PageSize), //页尺寸 new SqlParameter("@PageIndex", PageIndex), //页码 new SqlParameter("@doCount", doCount) //返回记录总数,非 0 值则返回 }; return(SqlHelper2.ExecuteTable(CommandType.StoredProcedure, "SP_Pagination", param)); }
/// <summary> /// 分页函数,执行SP_Pagination3分页操作 /// </summary> /// <param name="tblName">表名</param> /// <param name="strGetFields">需要返回的列</param> /// <param name="fldName">排序的字段名</param> /// <param name="PageSize">页尺寸</param> /// <param name="PageIndex">页码</param> /// <param name="strwhere">查询条件(注意: 不要加where)</param> /// <returns></returns> public static DataTable GetDataTableOfRow_Number(string tblName, string strGetFields, string fldName, int PageSize, int PageIndex, string strwhere) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@tblName", tblName), //表名 new SqlParameter("@strGetFields", strGetFields), //需要返回的列 new SqlParameter("@fldName", fldName), //排序的字段名 new SqlParameter("@PageSize", PageSize), //页尺寸 new SqlParameter("@PageIndex", PageIndex), //页码 new SqlParameter("@strwhere", strwhere), //查询条件(注意: 不要加where) }; //SqlParameter parm1 = new SqlParameter("@WebName", SqlDbType.Image); //parm1.Value = imageb; return(SqlHelper2.ExecuteTable(CommandType.StoredProcedure, "SP_Pagination3", param)); }