Advertisement
username_leta

iliminar delect

Apr 13th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim ConnectionString As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "pedro..accdb")
  2. Dim query As String = "DELETE FROM Clientes WHERE ID = @IDCliente"
  3.  
  4. Dim command As New OleDbCommand(query, ConnectionString)
  5.  
  6. ' Elimina apenas o cliente que consta na Textbox
  7. command.Parameters.Add("@IDCliente", OleDbType.Integer).Value = IDClienteTextbox.Text  
  8.  
  9. ConnectionString.Open()
  10.  
  11. Dim x As Integer = command.ExecuteNonQuery()
  12.  
  13. If x < 1 Then
  14.      MessageBox.Show("Erro ao eliminar", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
  15. Else
  16.      MessageBox.Show("Eliminado com sucesso!", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
  17. End If
  18.  
  19. ConnectionString.Close()
  20. command = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement