ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

09-Removing Academic Year

Today, I’m going to teach you how to removed the “Academic Year” in Ms Access Database using Visual Basic 2008.

 

Let’ begin:

 

Open the file which is “StudentInformation” and add a Button and place it under the DataGridView inside the “Academic Year” GroupBox in the Form. Name the Button “btnsydelete” and it will look like this.
removingsy_form1
After setting up the Form, double click the “Delete” Button and add this following code inside the “Click” event handler for removing the record in Ms Access Database.

  1. Private Sub btnsydelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsydelete.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 tblsy WHERE SYID =" & dtgsylist.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)
  12.  
  13. MsgBox("School Year 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

Finally, press F5 to run on the keyboard to run your project and click any record in the DatagridView you want to remove and hit the “Delete” Button to fire the code in the method.

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

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