Example #1
0
        public void load()
        {
            DbHelpParam dhp = new DbHelpParam(sql_count, fd.CommType, fd.DataParm, fd.ConnProvider);

            um.records_count = Convert.ToInt32(DbHelp.Scalar(dhp).ToString());

            dhp.SQL   = sql;
            datatable = DbHelp.GetDataTable_Paging(dhp, um.page_index, um.page_size);//参数需要优化
        }
Example #2
0
        /// <summary>
        /// 第一行第一列 可能为null
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pCmdType">设置CommandType</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public static object Scalar(string pSQL, CommandType pCmdType, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pCmdType, pArrParam);

            return(Scalar(dhp));
        }
Example #3
0
        /// <summary>
        /// 第一行第一列 可能为null
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <returns></returns>
        public static object Scalar(string pSQL)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(Scalar(dhp));
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public IDataReader Read(string pSQL, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(Read(dhp));
        }
Example #5
0
        public DataTable GetDataTable()
        {
            DbHelpParam dhp = new DbHelpParam(this._sql, fd.CommType, fd.DataParm, fd.ConnProvider);

            return(DbHelp.GetDataTable(dhp));
        }
Example #6
0
        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
        }
Example #7
0
        /// <summary>
        /// 第一行第一列 找不到时默认返回 pReturn
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pCmdType">设置CommandType</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <param name="pReturn"></param>
        /// <returns></returns>
        public static string First(string pSQL, CommandType pCmdType, IDataParameter[] pArrParam, string pReturn)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pCmdType, pArrParam);

            return(First(dhp, pReturn));
        }
Example #8
0
        /// <summary>
        /// 插入,更新或删除
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pCmdType">设置CommandType</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public static int Update(string pSQL, CommandType pCmdType, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pCmdType, pArrParam);

            return(Update(dhp));
        }
Example #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <returns></returns>
        public static DataSet GetDataSet(string pSQL)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(GetDataSet(dhp));
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public static DataTable GetDataTable(string pSQL, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(GetDataTable(dhp));
        }
Example #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pCmdType">设置CommandType</param>
        /// <returns></returns>
        public static DataTable GetDataTable(string pSQL, CommandType pCmdType)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pCmdType);

            return(GetDataTable(dhp));
        }
Example #12
0
        /// <summary>
        /// 第一行第一列 找不到时默认返回 pReturn
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <param name="pReturn"></param>
        /// <returns></returns>
        public string First(string pSQL, IDataParameter[] pArrParam, string pReturn)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(First(dhp, pReturn));
        }
Example #13
0
        /// <summary>
        /// 第一行第一列 可能为null
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public object Scalar(string pSQL, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(Scalar(dhp));
        }
Example #14
0
        /// <summary>
        /// 插入,更新或删除
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public int Update(string pSQL, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(Update(dhp));
        }
Example #15
0
        /// <summary>
        /// 第一行第一列 找不到时默认返回 string.Empty
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <returns></returns>
        public static string First(string pSQL)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(First(dhp, string.Empty));
        }
Example #16
0
        /// <summary>
        /// 第一行第一列 找不到时默认返回 str_return
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="str_return"></param>
        /// <returns></returns>
        public static string First(string pSQL, string pReturn)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(First(dhp, pReturn));
        }
Example #17
0
        /// <summary>
        /// 插入,更新或删除
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <returns></returns>
        public static int Update(string pSQL)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(Update(dhp));
        }
Example #18
0
        /// <summary>
        /// 第一行第一列 找不到时默认返回 string.Empty
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public static string First(string pSQL, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(First(dhp, string.Empty));
        }
Example #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pCmdType">设置CommandType</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public static DataSet GetDataSet(string pSQL, CommandType pCmdType, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pCmdType, pArrParam);

            return(GetDataSet(dhp));
        }
Example #20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <returns></returns>
        public static DataTable GetDataTable(string pSQL)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(GetDataTable(dhp));
        }
Example #21
0
        /// <summary>
        /// 用于分页 返回当前页的DataTable
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pPageIndex">当前页码</param>
        /// <param name="pPageSize">每页记录数</param>
        /// <returns></returns>
        public static DataTable GetDataTable_Paging(string pSQL, int pPageIndex, int pPageSize)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(GetDataTable_Paging(dhp, pPageIndex, pPageSize));
        }
Example #22
0
        public IDataReader GetRead()
        {
            DbHelpParam dhp = new DbHelpParam(this._sql, fd.CommType, fd.DataParm, fd.ConnProvider);

            return(DbHelp.Read(dhp));
        }
Example #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <returns></returns>
        public static IDataReader Read(string pSQL)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL);

            return(Read(dhp));
        }
Example #24
0
        public static IDataReader Read(string pSQL, CommandType pCmdType, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pCmdType, pArrParam);

            return(Read(dhp));
        }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pSQL">sql 语句</param>
        /// <param name="pArrParam">IDataParameter 参数数组</param>
        /// <returns></returns>
        public DataSet GetDataSet(string pSQL, IDataParameter[] pArrParam)
        {
            IDbHelpParam dhp = new DbHelpParam(pSQL, pArrParam);

            return(GetDataSet(dhp));
        }