Example #1
0
        /// <summary>
        ///
        /// select a set of rows from table t_RBSR_AUFW_u_Process.
        /// </summary>
        /// <param name="maxRowsToReturn">Max number of rows to return. If null or 0 all rows are returned.</param>
        /// <returns>returnListProcess[]</returns>
        public returnListProcess[] ListProcess(int?maxRowsToReturn)
        {
            returnListProcess[] rv = null;
            DBConnect();
            OdbcCommand cmd = new OdbcCommand();

            cmd.CommandText = "select" + (maxRowsToReturn.HasValue && maxRowsToReturn.Value != 0 ? " top " + maxRowsToReturn.Value.ToString() : "") + " " + "\"c_id\",\"c_u_Name\" from \"t_RBSR_AUFW_u_Process\"";
            cmd.Connection  = _dbConnection;
            OdbcDataReader           dr  = cmd.ExecuteReader();
            List <returnListProcess> rvl = new List <returnListProcess>();

            while (dr.Read())
            {
                returnListProcess cr = new returnListProcess();
                if (!dr.IsDBNull(0))
                {
                    cr.ID = dr.GetInt32(0);
                }
                else
                {
                    throw new Exception("Value 'null' is not allowed for 'ID'");
                }
                if (!dr.IsDBNull(1))
                {
                    cr.Name = dr.GetString(1);
                }
                else
                {
                    throw new Exception("Value 'null' is not allowed for 'Name'");
                }
                rvl.Add(cr);
            }
            dr.Close();
            dr.Dispose();
            rv = rvl.ToArray();
            cmd.Dispose();
            DBClose();
            return(rv);
        }
Example #2
0
        /// <summary>
        ///
        /// select a set of rows from table t_RBSR_AUFW_u_Process.
        /// </summary>
        /// <param name="maxRowsToReturn">Max number of rows to return. If null or 0 all rows are returned.</param>
        /// <param name="extendedCriteria">Statement appended to the end of the WHERE-clause</param>
        /// <param name="extentedParameters">Values bound to the query (?) marks in <code>extendedCriteria</code></param>
        /// <param name="extendedSortOrder">Statement appended to the end of the ORDER BY-clause</param>
        /// <returns>returnListProcess[]</returns>
        public returnListProcess[] ListProcess(int?maxRowsToReturn, string extendedCriteria, string[] extendedParameters, string extendedSortOrder)
        {
            returnListProcess[] rv = null;
            DBConnect();
            OdbcCommand cmd              = _dbConnection.CreateCommand();
            string      runTimeCriteria  = (extendedCriteria != null ? extendedCriteria.ToLower() : string.Empty).Replace("\"id\"", "\"c_id\"").Replace("\"name\"", "\"c_u_Name\"").Replace("\"description\"", "\"c_u_Description\"");
            string      runTimeSortOrder = (extendedSortOrder != null ? extendedSortOrder.ToLower() : string.Empty).Replace("\"id\"", "\"c_id\"").Replace("\"name\"", "\"c_u_Name\"").Replace("\"description\"", "\"c_u_Description\"");

            if (maxRowsToReturn.HasValue && maxRowsToReturn.Value > 0)
            {
                if (_dbConnection.Driver.ToLower().StartsWith("sql"))
                {
                    cmd.CommandText = "SELECT TOP " + maxRowsToReturn.Value + " \"c_id\", \"c_u_Name\", \"c_u_Description\" FROM \"t_RBSR_AUFW_u_Process\"" + (string.IsNullOrEmpty(runTimeCriteria) ? "" : " where (" + runTimeCriteria + ")") + (string.IsNullOrEmpty(runTimeSortOrder) ? "" : " order by " + runTimeSortOrder);
                }
                else
                {
                    cmd.CommandText = "SELECT \"c_id\", \"c_u_Name\", \"c_u_Description\" FROM \"t_RBSR_AUFW_u_Process\"" + (string.IsNullOrEmpty(runTimeCriteria) ? "" : " where (" + runTimeCriteria + ")") + (string.IsNullOrEmpty(runTimeSortOrder) ? "" : " order by " + runTimeSortOrder) + " LIMIT " + maxRowsToReturn.Value;
                }
            }
            else
            {
                cmd.CommandText = "SELECT \"c_id\", \"c_u_Name\", \"c_u_Description\" FROM \"t_RBSR_AUFW_u_Process\"" + (string.IsNullOrEmpty(runTimeCriteria) ? "" : " where (" + runTimeCriteria + ")") + (string.IsNullOrEmpty(runTimeSortOrder) ? "" : " order by " + runTimeSortOrder);
            }
            for (int i = 0; i < extendedParameters.Length; i++)
            {
                cmd.Parameters.Add("@ExtendedParam_" + i.ToString(), OdbcType.NVarChar);
                cmd.Parameters["@ExtendedParam_" + i.ToString()].Value = (object)extendedParameters[i];
            }
            OdbcDataReader           dr  = cmd.ExecuteReader();
            List <returnListProcess> rvl = new List <returnListProcess>();

            while (dr.Read())
            {
                returnListProcess cr = new returnListProcess();
                if (dr.IsDBNull(0))
                {
                    throw new Exception("Value 'null' is not allowed for 'ID'");
                }
                else
                {
                    cr.ID = dr.GetInt32(0);
                }
                if (dr.IsDBNull(1))
                {
                    throw new Exception("Value 'null' is not allowed for 'Name'");
                }
                else
                {
                    cr.Name = dr.GetString(1);
                }
                if (dr.IsDBNull(2))
                {
                    cr.Description = null;
                }
                else
                {
                    cr.Description = dr.GetString(2);
                }
                rvl.Add(cr);
            }
            dr.Close();
            dr.Dispose();
            rv = rvl.ToArray();
            cmd.Dispose();
            DBClose();
            return(rv);
        }