Free Source Code and Tutorials

Custom Search

06-Removing Year Level

Today, I’m going to remove whatever wrong records that have been saved in Ms Access Database. Deleting records in a system is not advisable but when you’re developing a system you will have to undergo many testing to make the system more accurate.



Let’s begin:



Open the project that I have created last time which is “StudentInformation” and do the Form just like this.
After setting up the Form, Double click the “Delete” Button to fire the event handler of it and add this following code for deleting the records in Ms Access Database.

  1. Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndelete.Click
  2. Try
  3. 'opening the connection
  4. con.Open()
  5. 'store a query to a variable that you have declared.
  6. query = "DELETE * FROM tbllevel WHERE LEVELID =" & dtgyllist.CurrentRow.Cells(0).Value & ""
  7. 'set a query and a connection string to a class that you have declared.
  8. da = New OleDb.OleDbDataAdapter(query, con)
  9. dt = New DataTable
  10. 'Filling the data in the datatable
  11. da.Fill(dt)
  13. MsgBox("Year Level has been removed.")
  14. txtyl.Clear()
  15. levelid = 0
  16. Catch ex As Exception
  17. 'catching error
  18. MsgBox(ex.Message)
  19. End Try
  20. con.Close()
  21. End Sub

Now, press F5 on the keyboard to run the project and click a record in the DataGridView that you’re going to remove and hit the “Delete” Button to fire the Code in the method.

Facebook Comments
(Visited 2 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: