示例#1
0
        public void RetornaString(ref SqlCommand cmd, ref string returnString)
        {
            this.Open();
            cmd.Connection = _Conexao;
            SqlDataReader dr;

            try
            {
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    returnString = dr[0].ToString();
                }

                dr.Close();
            }
            catch (Exception ex)
            {
                //throw new Exception(ex.ToString());
                Gerais.Enviar_Email_Para_Administradores("SGQ - ALM - EXCEPTION - RetornaString: ", "SQL:\n\n" + cmd.CommandText + "\n\n\nMensagem:\n\n" + ex.ToString());
            }
            finally
            {
                cmd.Dispose();
                this.Close();
            }
        }
示例#2
0
        public void RetornaArrayList(ref SqlCommand cmd, ref ArrayList Array)
        {
            this.Open();
            cmd.Connection = _Conexao;
            SqlDataReader dr;

            try
            {
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    Array.Add(dr[0].ToString());
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                //throw new Exception(ex.ToString());
                Gerais.Enviar_Email_Para_Administradores("SGQ - ALM - EXCEPTION - RetornaArrayList " + cmd.CommandText, ex.ToString());
            }
            finally
            {
                cmd.Dispose();
                this.Close();
            }
        }
        public string Get_String_(string sql)
        {
            try
            {
                OracleCommand    oOracleCommand = new OracleCommand(sql, OracleConnection);
                OracleDataReader DataReader     = oOracleCommand.ExecuteReader();
                oOracleCommand.Dispose();

                DataReader.Read();

                return(DataReader[0].ToString());
            }
            catch (Exception oEX)
            {
                //throw new Exception(oEX.Message);
                Gerais.Enviar_Email_Para_Administradores("Get_String_", oEX.Message.ToString());
                return(null);
            }
        }
示例#4
0
        public void Executar(ref OracleDataReader DataReader_Comandos, int Qte_Comandos)
        {
            if (DataReader_Comandos == null || DataReader_Comandos.HasRows == false)
            {
                return;
            }

            if (Qte_Comandos <= 1)
            {
                while (DataReader_Comandos.Read())
                {
                    try
                    {
                        this.Executar(DataReader_Comandos["Conteudo"].ToString());
                    }
                    catch (Exception oEX)
                    {
                        Gerais.Enviar_Email_Para_Administradores("SGQ - ALM - EXCEPTION - Executar ", oEX.ToString().Replace("\n", "<br />"));
                    }
                }
            }
            else
            {
                StringBuilder Conjunto_Comandos = new StringBuilder();
                int           cont = 0;
                while (DataReader_Comandos.Read())
                {
                    Conjunto_Comandos.Append(DataReader_Comandos["Conteudo"].ToString());
                    cont = cont + 1;
                    if (cont >= Qte_Comandos)
                    {
                        this.Executar(Conjunto_Comandos.ToString());
                        Conjunto_Comandos.Clear();
                        cont = 0;
                    }
                }
                if (cont > 0)
                {
                    Executar(Conjunto_Comandos.ToString());
                }
            }
        }
 public OracleDataReader Get_DataReader(string sql)
 {
     try
     {
         OracleCommand oOracleCommand = new OracleCommand($"{this.Sid}.GET_QCALM11SQL_V2", OracleConnection);
         oOracleCommand.CommandType = CommandType.StoredProcedure;
         oOracleCommand.Parameters.Add(new OracleParameter("QCALM11SQL", OracleDbType.Clob));
         oOracleCommand.Parameters.Add("RS", OracleDbType.RefCursor);
         oOracleCommand.Parameters[0].Value     = sql;
         oOracleCommand.Parameters[1].Direction = ParameterDirection.Output;
         OracleDataReader DataReader = oOracleCommand.ExecuteReader();
         oOracleCommand.Dispose();
         return(DataReader);
     }
     catch (Exception oEX)
     {
         //throw new Exception(oEX.Message);
         Gerais.Enviar_Email_Para_Administradores("Open QC11PRD1.GET_QCALM11SQL_V2", oEX.Message.ToString() + "<br/><br/>" + sql);
         return(null);
     }
 }
示例#6
0
        public void RetornaDataTable(ref SqlCommand cmd, ref DataTable returnDataTable)
        {
            this.Open();
            cmd.Connection = _Conexao;
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            try
            {
                da.Fill(returnDataTable);
            }
            catch (Exception ex)
            {
                //throw new Exception(ex.ToString());
                Gerais.Enviar_Email_Para_Administradores("SGQ - ALM - EXCEPTION - RetornaDataTable " + cmd.CommandText, ex.ToString());
            }
            finally
            {
                cmd.Dispose();
                da.Dispose();
                this.Close();
            }
        }
示例#7
0
        public int ExecuteNonQuery(string cmdText, CommandType cmdType, params IDbDataParameter[] parameters)
        {
            int        Retorno = 0;
            IDbCommand cmd     = CriarComando(cmdText, cmdType, parameters);

            try
            {
                Retorno = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Retorno = -1;
                //throw new Exception(ex.ToString());
                Gerais.Enviar_Email_Para_Administradores("SGQ - ALM - EXCEPTION - ExecuteNonQuery ", ex.ToString().Replace("\n", "<br />") + "<br /><br />" + cmdText.Replace("\n", "<br />"));
            }
            finally
            {
                cmd.Dispose();
                this.Close();
            }
            return(Retorno);
        }
示例#8
0
        public int Executar(SqlCommand cmd)
        {
            int retorno = 0;

            cmd.CommandType    = CommandType.Text;
            cmd.Connection     = this.connection;
            cmd.CommandTimeout = 0;
            try
            {
                if (this.connection.State != ConnectionState.Open)
                {
                    this.connection.Open();
                }

                cmd.ExecuteNonQuery();
            }
            catch (Exception oEX)
            {
                retorno = -1;
                Gerais.Enviar_Email_Para_Administradores("SGQ - Executar - EXCEPTION - ", oEX.ToString().Replace("\n", "<br />") + "<br /><br />" + cmd.CommandText.Replace("\n", "<br />"));
            }

            return(retorno);
        }