I have a log in form with max attempts of 3 then the program will automatically closed, but i want to find the code to block the user to log in with a time interval..Im using VB 2008(VB.net) and MS ACCESS 2010 as back end..
Here's my code:
Here's my code:
Code:
Imports System.Data.OleDb
Public Class LogForm
Dim Attempt As Integer = 1
Dim con As New OleDbConnection
Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\GDPCC\gdpcc.mdb"
End Sub
Public Function ask()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
con.Open()
Dim da As New OleDbDataAdapter("select * from gdpccTable", con)
da.Fill(dt)
For Each datarow In dt.Rows
If TextBox1.Text = datarow.item(7) And TextBox2.Text = datarow(8) Then
con.Close()
Return True
End If
Next
con.Close()
Return False
End Function
Private Sub login_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login_button.Click
If ask() = True Then
EmpForm.Show()
Me.Hide()
MessageBox.Show("WELCOME '" & TextBox1.Text & "'")
TextBox1.Text = ""
TextBox2.Text = ""
ElseIf TextBox1.Text = "" And TextBox2.Text = "" Then
MessageBox.Show("Input Username and Password")
ElseIf TextBox1.Text = "" Then
MessageBox.Show("Input Username")
TextBox2.Text = ""
ElseIf TextBox2.Text = "" Then
MessageBox.Show("Input Password")
TextBox1.Text = ""
ElseIf TextBox1.Text = "admin" And TextBox2.Text = "pass" Then
MessageBox.Show("Welcome Admin!!!")
AdminForm.Show()
Me.Hide()
TextBox1.Text = ""
TextBox2.Text = ""
ElseIf Attempt = 3 Then
MsgBox("Maximum number of Attempts(3), Program will now Shutdown")
TextBox1.Text = ""
TextBox2.Text = ""
Me.Close()
ElseIf ask() = False Then
MessageBox.Show("Invalid Username and Password! You currently have reached Attempt" & Attempt & " of 3.")
Attempt = Attempt + 1
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End If
End Sub
End Class
Comment