I need a vb code as below
This is my login page
This is my login page code
Private Sub StudentLoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StudentLoginButton.Click
Dim connection As New OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0;Data Source = ../Data/Student.accdb;")
Dim command As New OleDbCommand("SELECT * FROM Student WHERE Index = @username AND IC = @password", connection)
Dim MyAdapter_A As OleDbDataAdapter = New OleDbDataAdapter("Select * from Student", connection)
Dim ds As DataSet = New DataSet()
Dim usernameParam As New OleDbParameter("@username", Me.TextBox3.Text)
Dim passwordParam As New OleDbParameter("@password", Me.TextBox4.Text)
command.Parameters.Add(usernameParam)
command.Parameters.Add(passwordParam)
command.Connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
If TextBox3.Text = "" Or TextBox4.Text = "" Then Exit Sub
If reader.HasRows Then
MessageBox.Show("You are authenticated")
Form2.Show()
Me.Hide()
Me.Validate()
Else
MessageBox.Show("Username and Password are not found")
End If
command.Connection.Close()
End Sub
After login, the 2 page will be access the database .accdb and show the database by login variable i have no idea on the search button with function access database
This my Result form code
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbCommand
Public Class Result_Info
Private Sub Result_Info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Connection As New OleDbConnection
Dim command As New OleDbCommand
Dim dt As New DataTable
Connection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = ../Data/Student.accdb;")
Connection.Open()
command = New OleDbCommand("SELECT * FROM Result", Connection)
Dim adap As New OleDbDataAdapter(command)
adap.Fill(dt)
Label6.Text = dt.Rows(0)("Code").ToString()
Label7.Text = dt.Rows(0)("Description").ToString()
Label8.Text = dt.Rows(0)("Grade").ToString()
command.ExecuteNonQuery()
Connection.Close()
End Sub
and "previous" and "next" button
The is my code
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.OleDb.OleDbCommand
Public Class Finance_Info
Private Sub Finance_Info_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Connection As New OleDbConnection
Dim command As New OleDbCommand
Dim dt As New DataTable
Connection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source = ../Data/Student.accdb;")
Connection.Open()
command = New OleDbCommand("SELECT * FROM Finance", Connection)
Dim adap As New OleDbDataAdapter(command)
adap.Fill(dt)
Label7.Text = dt.Rows(0)("Description").ToString()
Label8.Text = dt.Rows(0)("Payment Date").ToString()
Label9.Text = dt.Rows(0)("Amount").ToString()
Label10.Text = dt.Rows(0)("Status").ToString()
command.ExecuteNonQuery()
Connection.Close()
End Sub