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(); } }
public int ExecuteNonQuery(DbCommand scdCommand) { try { DbConnection Conn = Conexao.abrirConexao(ConnectionStringName); scdCommand.Connection = Conn; return(scdCommand.ExecuteNonQuery()); } catch (DbException ex) { throw ex; ////TrataException.SetError(ex); //int numeroErro = LogEventError.Write(ex.Message); //throw new Exception("Ocorreu um erro ao tentar acessar o Banco de Dados. Err.ID " + numeroErro); } catch (Exception ex2) { string x = ex2.Message; throw new Exception(ex2.Message, ex2); } finally { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
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(); } }
public object ExecuteScalar(DbCommand scdCommand) { try { DbConnection Conn = Conexao.abrirConexao(ConnectionStringName); scdCommand.Connection = Conn; return(scdCommand.ExecuteScalar()); } catch (Exception ex) { throw ex; } finally { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public object ExecuteNonQuery(DbCommand scdCommand, bool bolHasReturnValue) { try { DbConnection Conn = Conexao.abrirConexao(ConnectionStringName); scdCommand.Connection = Conn; return(scdCommand.ExecuteNonQuery()); } catch (Exception ex) { throw ex; } finally { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DbDataReader ExecuteReader(DbCommand scdCommand) { try { OracleCommand cm = (OracleCommand)scdCommand; OracleConnection cn = (OracleConnection)Conexao.abrirConexao(ConnectionStringName); cm.Connection = cn; cm.Parameters.Add(CursorRetorno, OracleType.Cursor).Direction = ParameterDirection.Output; return(cm.ExecuteReader(CommandBehavior.CloseConnection)); } catch (Exception ex) { throw ex; } finally { //Conexao.fecharConexao(scdCommand.Connection); //scdCommand.Dispose(); } }
public int InserirOracle(DbCommand scdCommand) { try { DbConnection Conn = Conexao.abrirConexao(ConnectionStringName); scdCommand.Connection = Conn; this.AddOutParameter(scdCommand, "IDENTITY", DbType.Int32, 4); scdCommand.ExecuteNonQuery(); return((int)scdCommand.Parameters["IDENTITY"].Value); } catch (Exception ex) { throw ex; } finally { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public object ExecuteScalar(DbCommand scdCommand) { try { DbConnection Conn = Conexao.abrirConexao(); scdCommand.Connection = Conn; return(scdCommand.ExecuteScalar()); } 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 { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DbDataReader ExecuteReader(DbCommand scdCommand) { try { OracleCommand cm = (OracleCommand)scdCommand; OracleConnection cn = (OracleConnection)Conexao.abrirConexao(); cm.Connection = cn; cm.Parameters.Add(CursorRetorno, OracleType.Cursor).Direction = ParameterDirection.Output; return(cm.ExecuteReader(CommandBehavior.CloseConnection)); } 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 { //Conexao.fecharConexao(scdCommand.Connection); //scdCommand.Dispose(); } }
public int InserirOracle(DbCommand scdCommand) { try { DbConnection Conn = Conexao.abrirConexao(); scdCommand.Connection = Conn; this.AddOutParameter(scdCommand, "IDENTITY", DbType.Int32, 4); scdCommand.ExecuteNonQuery(); return((int)scdCommand.Parameters["IDENTITY"].Value); } 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 { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DataTable ExecuteOracleDataTableWithoutCursor(DbCommand scdCommand) { try { OracleCommand cm = (OracleCommand)scdCommand; OracleConnection cn = (OracleConnection)Conexao.abrirConexao(ConnectionStringName); cm.Connection = cn; //cm.Parameters.Add(CursorRetorno, OracleType.Cursor).Direction = ParameterDirection.Output; OracleDataReader dr = cm.ExecuteReader(CommandBehavior.CloseConnection); DataTable dt = new DataTable(); dt.Load(dr); return(dt); } catch (Exception ex) { throw ex; } finally { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DataTable ExecuteOracleDataTable(DbCommand scdCommand) { try { OracleCommand cm = (OracleCommand)scdCommand; OracleConnection cn = (OracleConnection)Conexao.abrirConexao(); cm.Connection = cn; cm.Parameters.Add(CursorRetorno, OracleType.Cursor).Direction = ParameterDirection.Output; OracleDataReader dr = cm.ExecuteReader(CommandBehavior.CloseConnection); DataTable dt = new DataTable(); dt.Load(dr); return(dt); } catch (Exception ex) { int numeroErro = LogEventError.Write(ex.Message); throw new Exception(string.Format("Ocorreu um erro número:{0}. Descrição: {1}", numeroErro, ex.Message)); } finally { Conexao.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }