private void CargarTabla() { con = new SqlConnection("Data Source=DESKTOP-7UG5AJD\\SQLEXPRESS02;Initial Catalog=RentCar;Integrated Security=True"); con.Open(); string sql = "select * from InspeccionV "; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataTable dt = new DataTable(); da.Fill(dt); DgvInspeccion.DataSource = dt; DgvInspeccion.Refresh(); con.Close(); }
private void CargarTabla() { if (con.State != ConnectionState.Open) { con.Open(); } string sql = "select * from InspeccionV "; SqlDataAdapter da = new SqlDataAdapter(sql, con); DataTable dt = new DataTable(); da.Fill(dt); DgvInspeccion.DataSource = dt; DgvInspeccion.Refresh(); con.Close(); }
private void BtBorrar_Click(object sender, EventArgs e) { try { con = new SqlConnection("Data Source=DESKTOP-7UG5AJD\\SQLEXPRESS02;Initial Catalog=RentCar;Integrated Security=True"); con.Open(); string sql = "DELETE FROM InspeccionV WHERE IdVehiculos = " + "'" + TxtIdInspeccion.Text + "'" + ""; SqlCommand comando = new SqlCommand(sql, con); comando.ExecuteNonQuery(); MessageBox.Show("Registro Borrado"); DgvInspeccion.Refresh(); con.Close(); } catch (Exception) { MessageBox.Show("Ha ocurrido un error"); } }
private void BtBorrar_Click(object sender, EventArgs e) { try { if (con.State != ConnectionState.Open) { con.Open(); } string sql = "DELETE FROM InspeccionV WHERE IdVehiculos = " + "'" + TxtIdInspeccion.Text + "'" + ""; SqlCommand comando = new SqlCommand(sql, con); comando.ExecuteNonQuery(); MessageBox.Show("Registro Borrado"); DgvInspeccion.Refresh(); con.Close(); } catch (Exception) { MessageBox.Show("Ha ocurrido un error"); } }