04-Add Year Level

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.
[vbnet]

‘declare a string variable to store a query in it
Public query As String
‘declare a class that set a data command and a database connection to fill and update the datasource
Public da As New OleDb.OleDbDataAdapter
‘declare a class that represent a specific table in a database.
Public dt As New DataTable
[/vbnet]

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.
[vbnet]
Private Sub btnylsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnylsave.Click
Try
‘opening the connection
con.Open()
‘store a query to a variable that you have declared.
query = “INSERT INTO tbllevel (YLEVEL) VALUES (‘” & txtyl.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
da.Fill(dt)

MsgBox(“New Year Level has been saved.”)

Catch ex As Exception
‘catching error
MsgBox(ex.Message)
End Try
‘closing the connection
con.Close()
End Sub
[/vbnet]

 

Readers might read also:

 

 

 

Leave a Comment