/// <summary> /// 绑定Repeater /// </summary> /// <param name="pSql">sql 语句</param> /// <param name="pList">Repeater</param> public static void BGRepeater(string pSql, Repeater pList) { using (IDataReader dr = DbHelp.Read(pSql)) { pList.DataSource = dr; pList.DataBind(); } }
public IDataReader GetRead() { DbHelpParam dhp = new DbHelpParam(this._sql, fd.CommType, fd.DataParm, fd.ConnProvider); return(DbHelp.Read(dhp)); }
public void load() { IDataReader records; DbHelpParam dhp; #region 获取总记录 if (fd.PageCount > 0) { um.records_count = fd.PageCount * um.page_size; } else { dhp = new DbHelpParam(fd.SQLCount, fd.CommType, fd.DataParm, fd.ConnProvider); um.records_count = Convert.ToInt32(DbHelp.Scalar(dhp)); } if (string.Compare(fd.SQLRead.Substring(0, 6), "select", true) == 0) { fd.SQLRead = "select top " + (um.page_index * um.page_size) + fd.SQLRead.Substring(6);//因records.RecordsAffected性能问题 需要加top } #endregion #region 获取当前页主键 sql_key 集合 int PageLowerBound, PageUpperBound; PageLowerBound = (um.page_index - 1) * um.page_size; //每页开始时 PageUpperBound = PageLowerBound + um.page_size - 1; //每页最后时 StringBuilder sbSQL = new StringBuilder(); int i = 0; dhp = new DbHelpParam(fd.SQLRead, fd.CommType, fd.DataParm, fd.ConnProvider); using (records = DbHelp.Read(dhp)) { //跳过前面查询 while (0 < PageLowerBound) { if (!records.Read()) { break; } PageLowerBound--; } const string dehao = ","; while ((i < um.page_size) && records.Read()) { sbSQL.Append(records[0]); sbSQL.Append(dehao); i++; } records.Close(); } if (sbSQL.Length > 0) { sbSQL.Remove(sbSQL.Length - 1, 1); this._sql = string.Format(fd.SQL, sbSQL.ToString()); } else { this._sql = string.Format(fd.SQL, '0'); } #endregion }