public bool MeliminarLibro(clsEliminar elim) { MySqlConnection conexxion = new MySqlConnection(); MySqlCommand comando = new MySqlCommand(); try { conexxion.ConnectionString = "server=192.168.1.74; database=biblioteca; user=admin; pwd=itsur123;"; conexxion.Open(); string strSQL = "delete from libros where Id = " + elim.ID; comando = new MySqlCommand(strSQL, conexxion); comando.ExecuteNonQuery(); } catch { return(false); } finally { comando.Dispose(); conexxion.Close(); conexxion.Dispose(); } return(true); }
private void btnEliminar_Click(object sender, EventArgs e) { clsEliminar Elimina = new clsEliminar(); Elimina.ID = Convert.ToInt32(txtEliminar.Text); DaoEliminar metodo = new DaoEliminar(); if (metodo.MeliminarLibro(Elimina)) { MessageBox.Show("Eliminado Correctamente"); this.Visible = false; } else { MessageBox.Show("Algo salio mal"); } }