Help - How to create a Login tracker?
As my title suggests, I want to create a form that can track who and when did the people logs in .
First of all, I have no clue how to start off and hence I would like help, advices or sample codes to see it as reference.
Anyway, I have created a Login form where it validates its credentials via an acess file, which is also my database.
this is the code of my login form in case you need it
Imports System.Data
Imports System.Data.OleDb
Public Class Login
Public Sub login()
Dim userName As String = Me.txtLoginName.Text.Trim
Dim userPassword As String = Me.txtLoginPassword.Text.Trim
'Connection Part
Dim ConnString As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Documents and Settings\Administrator\Desktop\New Folder\New Folder\Proj1.mdb"
Dim connection As New OleDbConnection(ConnString)
Dim command As New OleDbCommand("SELECT COUNT(*) FROM Users WHERE Login = @Login AND Password = @Password", connection)
With command.Parameters
.AddWithValue("@Login", userName)
.AddWithValue("@Password", userPassword)
End With
connection.Open()
Dim tempBoolean As Boolean = False
If CInt(command.ExecuteScalar()) = 0 Then
MsgBox("Access Denied - Login Again", , "Login Form")
Else
tempBoolean = True
MsgBox("Access Granted", , "Login Form")
End If
connection.Close()
If tempBoolean Then
Me.Hide()
Admin.Show()
Else
'Present the screen if login fails
Me.Show()
'Clear the contents
txtLoginName.Text = String.Empty
txtLoginPassword.Text = String.Empty
End If
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
If txtLoginName.Text = String.Empty And txtLoginPassword.Text = String.Empty Then
MsgBox("Please enter your Login Name and Password")
ElseIf txtLoginName.Text = String.Empty Then
MsgBox("Please enter your Login Name", , "Login Form")
ElseIf txtLoginPassword.Text = String.Empty Then
MsgBox("Please enter in your Password", , "Login Form")
End If
login()
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class
Thanks in advance
|