09-Removing Academic Year

0
387

This tutorial is all about 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.

 

Readers might read also:

 

 

 

Facebook Comments
(Visited 80 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here