Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim ConnectionString As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Application.StartupPath & "pedro..accdb")
- Dim query As String = "UPDATE Clientes SET [Nome] = @Nome, [Empresa] = @Empresa WHERE ID = @IDCliente"
- Dim command As New OleDbCommand(query, ConnectionString)
- command.Parameters.Add("@Nome", OleDbType.VarChar).Value = NomeTextbox.Text
- command.Parameters.Add("@Empresa", OleDbType.VarChar).Value = EmpresaTextbox.Text
- ' Actualiza apenas os dados do cliente que consta na Textbox
- command.Parameters.Add("@IDCliente", OleDbType.Integer).Value = IDClienteTextbox.Text
- ConnectionString.Open()
- Dim x As Integer = command.ExecuteNonQuery()
- If x < 1 Then
- MessageBox.Show("Erro ao actualizar", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
- Else
- MessageBox.Show("Actualizado com sucesso!", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
- End If
- ConnectionString.Close()
- command = Nothing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement