Пример #1
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);
        }