예제 #1
0
        public DataSet ExecuteDbDataSet(DbCommand scdCommand)
        {
            DbConnection Conn = Conexao.abrirConexao(ConnectionStringName);

            scdCommand.Connection = Conn;

            DbDataAdapter daAdapter = Conexao.obterDataAdapter(scdCommand.Connection);

            try
            {
                DataSet dsDados = new DataSet();
                daAdapter.SelectCommand = scdCommand;
                daAdapter.Fill(dsDados);

                daAdapter = null;
                return(dsDados);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                daAdapter.Dispose();
                Conexao.fecharConexao(scdCommand.Connection);
                scdCommand.Dispose();
            }
        }
예제 #2
0
        public DataSet ExecuteDbDataSet(DbCommand scdCommand)
        {
            DbConnection Conn = Conexao.abrirConexao();

            scdCommand.Connection = Conn;

            DbDataAdapter daAdapter = Conexao.obterDataAdapter(scdCommand.Connection);

            try
            {
                DataSet dsDados = new DataSet();
                daAdapter.SelectCommand = scdCommand;
                daAdapter.Fill(dsDados);

                daAdapter = null;
                return(dsDados);
            }
            catch (Exception ex)
            {
                int numeroErro = LogEventError.Write(ex.Message);
                throw new Exception("Ocorreu um erro ao tentar acessar o Banco de Dados. Err.ID " + numeroErro);
            }
            finally
            {
                daAdapter.Dispose();
                Conexao.fecharConexao(scdCommand.Connection);
                scdCommand.Dispose();
            }
        }
예제 #3
0
        public DataTable ExecuteDbDataTable(DbCommand scdCommand, DbConnection Conn)
        {
            scdCommand.Connection = Conn;

            DbDataAdapter daAdapter = Conexao.obterDataAdapter(scdCommand.Connection);

            try
            {
                DataTable dtTable = new DataTable();
                daAdapter.SelectCommand = scdCommand;
                daAdapter.Fill(dtTable);

                return(dtTable);
            }
            catch (Exception ex)
            {
                int numeroErro = LogEventError.Write(ex.Message);
                throw new Exception("Ocorreu um erro ao tentar acessar o Banco de Dados. Err.ID " + numeroErro);
            }
            finally
            {
                daAdapter.Dispose();
                scdCommand.Dispose();
            }
        }
예제 #4
0
        public DataTable ExecuteDbDataTable(DbCommand scdCommand, DbConnection Conn)
        {
            scdCommand.Connection = Conn;

            DbDataAdapter daAdapter = Conexao.obterDataAdapter(scdCommand.Connection);

            try
            {
                DataTable dtTable = new DataTable();
                daAdapter.SelectCommand = scdCommand;
                daAdapter.Fill(dtTable);

                return(dtTable);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                daAdapter.Dispose();
                scdCommand.Dispose();
            }
        }