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.
Open your project entitled “StudentInformation” that i have made previously.After that, set a Form just like this.
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.
- '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
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.
- Private Sub btnylsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnylsave.Click
- 'opening the connection
- '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
- MsgBox("New Year Level has been saved.")
- Catch ex As Exception
- 'catching error
- End Try
- 'closing the connection
- End Sub
Readers might read also: