update/edit vb access


/ Published in: VB.NET
Save to your folder(s)

edit database using vb + access


Copy this code and paste it in your HTML
  1. Private Sub EditRental()
  2. Dim RentalDR As DataRow = frmRental.dsRental.RENTAL.Rows.Find(CInt(lblID.Text))
  3. uProceed = True '-- not needed for basic edit/update
  4.  
  5. Try
  6. '' Edit anything you want to edit
  7. RentalDR.BeginEdit()
  8. RentalDR("rDate") = Format(dtpDate.Value, My.Settings.DateFormat)
  9. RentalDR("rDesc") = txtDesc.Text
  10. RentalDR("rAmount") = CDbl(txtAmount.Text)
  11. RentalDR("rStatus") = cmbStatus.Text
  12. RentalDR.EndEdit()
  13. Catch ex As Exception
  14. iProceed = False ' Block procedures if exception happens.
  15. MessageBox.Show("Please check your input. Make sure all input is correct.", "Invalid Input(s)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  16. End Try
  17.  
  18. If uProceed = True Then
  19. Try
  20. frmRental.daRental.Update(frmRental.dsRental)
  21. MessageBox.Show("Database successfully updated.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)
  22.  
  23. Me.Close()
  24. Catch ex As Exception
  25. MessageBox.Show("Somehow I cannot update the database. =(", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  26. End Try
  27. End If
  28. End Sub

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.