Beispiel #1
0
        public DataSet FillDataSet(string commandID, params object[] parameters)
        {
            string      cmdText     = GetCommandText(commandID);
            CommandType commandType = GetCommandType(commandID);

            OracleParameter[] param = ConvertParam(parameters, ref cmdText, commandType);
            Util.Log.Debug(GetNoParamCommandText(commandID, cmdText, param));

            return(ORACLEHelper.ExecuteDataset(ConnectionString, commandType, cmdText, param));
        }
Beispiel #2
0
        public DataTable FillDataTable(string commandID, params object[] parameters)
        {
            string      cmdText     = GetCommandText(commandID);
            CommandType commandType = GetCommandType(commandID);

            OracleParameter[] param = ConvertParam(parameters, ref cmdText, commandType);
            Util.Log.Debug(GetNoParamCommandText(commandID, cmdText, param));

            DataTable dtData = ORACLEHelper.ExecuteDataset(ConnectionString, commandType, cmdText, param).Tables[0];

            dtData.TableName = "Table";
            return(dtData);
        }
Beispiel #3
0
        public DataTable GetDataPage(string commandID, int currentPage, int pageSize, out int TotalCount, out int PageCount, params object[] parameters)
        {
            TotalCount = 0;
            PageCount  = 0;
            string      cmdText     = GetCommandText(commandID);
            CommandType commandType = GetCommandType(commandID);

            OracleParameter[] param = ConvertParam(parameters, ref cmdText, commandType);

            //计算总记录条数
            if (commandType == CommandType.Text)
            {
                string countCmd = cmdText;
                Regex  regex    = new Regex("[\\s]order[\\s]", RegexOptions.IgnoreCase);
                if (regex.IsMatch(countCmd))
                {
                    Match match = regex.Match(countCmd);
                    countCmd = countCmd.Substring(0, match.Index);
                }
                if (!string.IsNullOrEmpty(countCmd))
                {
                    countCmd = "\r\n    SELECT COUNT(0) FROM (" + countCmd + ") T";
                    Util.Log.Debug(GetNoParamCommandText(string.Empty, countCmd, param));
                    TotalCount = (int)ORACLEHelper.ExecuteScalar(ConnectionString, commandType, countCmd, param);
                }
            }
            else if (commandType == CommandType.StoredProcedure)
            {
                throw new Exception("不支持存储过程分页查询");
            }

            Util.Log.Debug(GetNoParamCommandText(commandID, cmdText, param));
            PageCount = GetPageCount(TotalCount, pageSize);
            if (currentPage == 0 || currentPage > PageCount)
            {
                currentPage = PageCount;
            }
            if (currentPage == 0)
            {
                currentPage = 1;
            }

            return(ORACLEHelper.ExecuteDataset(ConnectionString, commandType, cmdText, currentPage, pageSize, commandID, param).Tables[0]);
        }