public void Upd(Plataforma u) { using (OracleConnection conn = BaseDAO.GetConnection()) { //Define o comando using (OracleCommand cmd = new OracleCommand("PLATAFORMA_tapi.upd", conn)) { cmd.CommandType = CommandType.StoredProcedure; //Define parametros cmd.Parameters.Add("p_ID_PLATAFORMA", u.Id_Plataforma); cmd.Parameters.Add("p_NOME", u.Nome); //Executa try { conn.Open(); cmd.ExecuteNonQuery(); } catch (SqlException ex) { throw new Exception("Ocorreu o erro(BD): " + ex.Message); } catch (Exception ex) { throw new Exception("Erro: " + ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } } } }
public List<Plataforma> Get() { using (OracleConnection conn = BaseDAO.GetConnection()) { //Define o comando using (OracleCommand cmd = new OracleCommand("SELECT ID_PLATAFORMA, NOME FROM PLATAFORMA", conn)) { List<Plataforma> lista = new List<Plataforma>(); cmd.CommandType = CommandType.Text; //Executando o select OracleDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Plataforma p = new Plataforma(); p.Id_Plataforma = Convert.ToInt32(reader["ID_PLATAFORMA"]); p.Nome = Convert.ToString(reader["NOME"]); lista.Add(p); } return lista; } } }