Пример #1
0
 public bool ExecSelect(ref ArrayList ret_objection, ref DB_Result db_res, string sql)
 {
     if (this.m_gen_my_access == null)
     {
         ret_objection.Add((object)"Generic::ExecSelect::DataBase not set");
         return(false);
     }
     this.m_gen_dbStatement.KeepNames = this.KeepNames;
     if (this.m_gen_dbStatement.m_DB_SQL_CMD == ENUM_DB_SQL_CMD.select)
     {
         return(this.m_gen_my_access.SelectCommand(sql, ref ret_objection, ref this.m_gen_dbStatement, ref db_res));
     }
     ret_objection.Add((object)"Generic::ExecSelect::m_DB_SQL_CMD != ENUM_DB_SQL_CMD.select");
     return(false);
 }
Пример #2
0
        public bool SelectCommand(string sql_command, ref ArrayList ret_objection, ref DB_Statement db_st, ref DB_Result db_res)
        {
            if (!this.IsBackup)
            {
                this.i_monCpu.start_SQL();
            }
            ArrayList ret_list = new ArrayList();

            db_st.ExportLabels(ref ret_list);
            try
            {
                OdbcDataReader odbcDataReader = new OdbcCommand(sql_command, this.MyConnection).ExecuteReader();
                if (db_st.IsCount)
                {
                    if (odbcDataReader.Read())
                    {
                        db_st.count_Value = odbcDataReader.GetInt64(0);
                    }
                }
                else if (db_st.IsDistinct)
                {
                    while (odbcDataReader.Read())
                    {
                        string data = db_st.processExceptions(odbcDataReader[db_st.m_Distinct].ToString());
                        if (!db_st.var_distinct.Contains((object)data))
                        {
                            db_st.var_distinct.Add((object)data);
                            DB_Row new_row = new DB_Row();
                            new_row.allocField(data, db_st.m_Distinct);
                            db_res.AddRow(ref new_row);
                        }
                    }
                    db_st.var_distinct.Clear();
                }
                else if (db_st.IsSum)
                {
                    while (odbcDataReader.Read())
                    {
                        db_st.nu_sum += odbcDataReader.GetInt64(0);
                    }
                }
                else
                {
                    int  varMaxRowsRead = db_st.var_maxRowsRead;
                    bool flag           = false;
                    if (varMaxRowsRead > 0)
                    {
                        flag = true;
                    }
                    while (odbcDataReader.Read())
                    {
                        DB_Row new_row = new DB_Row();
                        for (int index = 0; index < ret_list.Count; ++index)
                        {
                            string label = ret_list[index] as string;
                            new_row.allocField(db_st.processExceptions(odbcDataReader[label].ToString()), label);
                        }
                        db_res.AddRow(ref new_row);
                        if (flag && --varMaxRowsRead == 0)
                        {
                            break;
                        }
                    }
                }
                odbcDataReader.Close();
            }
            catch (Exception ex)
            {
                ret_objection.Add((object)("##### SQL Failure: " + sql_command));
                ret_objection.Add((object)("##### Error: " + ex.Message));
                if (!this.IsBackup)
                {
                    this.i_monCpu.end_SQL();
                }
                return(false);
            }
            if (!this.IsBackup)
            {
                this.i_monCpu.end_SQL();
            }
            return(true);
        }