07-Add Academic Year


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.


Let’s begins:


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.

  1. Private Sub btnsySave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsySave.Click
  2. Try
  3. 'opening the connection
  4. con.Open()
  5. 'store a query to a variable that you have declared.
  6. query = "INSERT INTO tblsy (SY) VALUES ('" & txtsy.Text & "')"
  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("New School Year has been saved.")
  14. txtsy.Clear()
  16. Catch ex As Exception
  17. 'catching error
  18. MsgBox(ex.Message)
  19. End Try
  20. con.Close()
  21. End Sub


Readers might read also:



Facebook Comments


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.