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.
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.
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.
[vbnet] Private Sub btnsydelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsydelete.Click
‘opening the connection
‘store a query to a variable that you have declared.
query = “DELETE * FROM tblsy WHERE SYID =” & dtgsylist.CurrentRow.Cells(0).Value & “”
‘set a query and a connection string to a class that you have declared.
da = New OleDb.OleDbDataAdapter(query, con)
dt = New DataTable
‘Filling the data in the datatable
MsgBox(“School Year has been removed.”)
levelid = 0
Catch ex As Exception
[/vbnet] 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: