04-Add Year Level

0
366

This tutorial is all about Add Year Level.
In this tutorial I will teach you how to add and manage setting in the Student Information System. The settings are made up of two modules which is managing “year level” and “academic year”. This is very important because you can manage and also prevent the redundancy of records in every academic year and year level of a student.

This time we will focus on how to add the Year Level.

 

Let’s begin:

 

 

Open your project entitled “StudentInformation” that i have made previously.After that, set a Form just like this.

 

managesettings_form1

After setting up a Form, click a Module named “mod_coonection” in the solution explorer and declare all the class and variables that are needed.

  1. ''
  2. 'declare a string variable to store a query in it
  3. Public query As String
  4. 'declare a class that set a data command and a database connection to fill and update the datasource
  5. Public da As New OleDb.OleDbDataAdapter
  6. 'declare a class that represent a specific table in a database.
  7. Public dt As New DataTable

After declaring the class and variable, click a Form in the solution explorer and double click the Button inside of it. Do this following code for adding a year level of a student in the database.

  1. Private Sub btnylsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnylsave.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 tbllevel (YLEVEL) VALUES ('" & txtyl.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)
  12.  
  13. MsgBox("New Year Level has been saved.")
  14.  
  15. Catch ex As Exception
  16. 'catching error
  17. MsgBox(ex.Message)
  18. End Try
  19. 'closing the connection
  20. con.Close()
  21. End Sub

 

Readers might read also:

 

 

 

Facebook Comments
(Visited 48 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here