Last time we have finished the “Year Level” module of the student. Now, we will add another module which is “Academic Year” in the settings. This module allows you to manage the “Academic Year” of the students that contain adding, updating,retrieving and removing. We are now going to focus on how to add the “Academic Year” in Ms Access Database using Visual Basic 2008.
Open the project that I have created previously which is “StudentInformation” and do the Form just like this.
After setting up the Form, double click the “Save” Button inside the “Academic Year” GroupBox and do this following code for saving the “Academic Year” inside the event handler of a Button. It will look like this.
- Private Sub btnsySave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsySave.Click
- 'opening the connection
- 'store a query to a variable that you have declared.
- query = "INSERT INTO tblsy (SY) VALUES ('" & txtsy.Text & "')"
- '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("New School Year has been saved.")
- Catch ex As Exception
- 'catching error
- End Try
- End Sub
Readers might read also: