You are on page 1of 1

Public Class Form1

Dim attempts As Integer = 3


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
con.Open(constr)
cmd.ActiveConnection = con
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
Try
cmd.CommandText = "select user_name from accounts"
rs = cmd.Execute
If Not rs.EOF Then
cmd.CommandText = $"select user_name, lock from accounts where
user_name = '{TextBox1.Text}' and lock = false"
rs = cmd.Execute
If Not rs.EOF Then
HashedInputPassword = HashPassword(TextBox2.Text)
cmd.CommandText = $"Select * from Accounts where User_name =
'{TextBox1.Text}' And Pass_word = '{HashedInputPassword}'"
rs = cmd.Execute
If rs.EOF = False Then
TextBox1.Clear()
TextBox2.Clear()
CRUD.Show()
Me.Hide()
ElseIf TextBox1.Text = "" Or TextBox2.Text = "" Then
MessageBox.Show("Type your username or password")
Else
cmd.CommandText = $"Select * from Accounts where User_name
= '{TextBox1.Text}'"
rs = cmd.Execute
If rs.EOF = False Then
MessageBox.Show("Wrong password")
Else
MessageBox.Show("This account does not exist")
End If
End If
Else
MsgBox("Account is locked")
End If
Else
MsgBox("Account does not exists")
End If

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

End Sub
End Class

You might also like