public DataSet ExecuteDbDataSet(DbCommand scdCommand) { DbConnection Conn = ConexaoAntigo.abrirConexao(); scdCommand.Connection = Conn; DbDataAdapter daAdapter = ConexaoAntigo.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(); ConexaoAntigo.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DbCommand CreateCommand(System.Data.CommandType _CommandType, string _CommandToExecute) { ConexaoAntigo._ConnectionStringName = this.ConnectionStringName; DbProviderFactory Factory = ConexaoAntigo.GetDbProviderFactory(); DbCommand _DbCommand = Factory.CreateCommand(); _DbCommand.CommandText = _CommandToExecute; _DbCommand.CommandType = _CommandType; return(_DbCommand); }
public object ExecuteScalar(DbCommand scdCommand) { try { DbConnection Conn = ConexaoAntigo.abrirConexao(); scdCommand.Connection = Conn; return(scdCommand.ExecuteScalar()); } catch (Exception ex) { throw ex; } finally { ConexaoAntigo.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public object ExecuteNonQuery(DbCommand scdCommand, bool bolHasReturnValue) { try { DbConnection Conn = ConexaoAntigo.abrirConexao(); scdCommand.Connection = Conn; return(scdCommand.ExecuteNonQuery()); } catch (Exception ex) { throw ex; } finally { ConexaoAntigo.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DbDataReader ExecuteReader(DbCommand scdCommand) { try { OracleCommand cm = (OracleCommand)scdCommand; OracleConnection cn = (OracleConnection)ConexaoAntigo.abrirConexao(); 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 = ConexaoAntigo.abrirConexao(); scdCommand.Connection = Conn; this.AddOutParameter(scdCommand, "IDENTITY", DbType.Int32, 4); scdCommand.ExecuteNonQuery(); return((int)scdCommand.Parameters["IDENTITY"].Value); } catch (Exception ex) { throw ex; } finally { ConexaoAntigo.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DataTable ExecuteOracleDataTable(DbCommand scdCommand) { try { OracleCommand cm = (OracleCommand)scdCommand; OracleConnection cn = (OracleConnection)ConexaoAntigo.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) { throw ex; } finally { ConexaoAntigo.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public int ExecuteNonQuery(DbCommand scdCommand) { try { DbConnection Conn = ConexaoAntigo.abrirConexao(); scdCommand.Connection = Conn; return(scdCommand.ExecuteNonQuery()); } catch (DbException ex) { throw ex; } catch (Exception ex2) { string x = ex2.Message; throw new Exception(ex2.Message, ex2); } finally { ConexaoAntigo.fecharConexao(scdCommand.Connection); scdCommand.Dispose(); } }
public DataTable ExecuteDbDataTable(DbCommand scdCommand, DbConnection Conn) { scdCommand.Connection = Conn; DbDataAdapter daAdapter = ConexaoAntigo.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(); } }