Im currently doing an application which is when user plugged in usb drive, login form will pop up so user need to login first but if user failed login for three times, webcam will automatically capture. The problem here, how to make the webcam to automatically capture after user failed to login after three times? I already found code for webcam from google but I dont know how to connect these to code to solve my problem.
This is the code for login without errors (in case u wanna see my code)
Imports System.Data.OleDb
Public Class Login
Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
'Check if username or password is empty
If PasswordTextBox.Text = "" Or UsernameTextBox.Text = "" Then
MessageBox.Show("Please fill-up all fields!", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
'Clear all fields
PasswordTextBox.Text = ""
UsernameTextBox.Text = ""
'Focus on Username field
UsernameTextBox.Focus()
Else
' Connect to DB
Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\PutLock.mdb"
Try
'Open Database Connection
conn.Open()
Dim sql As String = "SELECT * FROM PutLockSignUp WHERE Username='" & UsernameTextBox.Text & "' AND Password = '" & PasswordTextBox.Text & "'"
Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
Dim sqlRead As OleDbDataReader = cmd.ExecuteReader()
If sqlRead.Read() Then
MainPage.Show()
Me.Hide()
Else
' If user enter wrong username or password
MessageBox.Show("Sorry, username or password not found!", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error)
'Clear all fields
PasswordTextBox.Text = ""
UsernameTextBox.Text = ""
'Focus on Username field
UsernameTextBox.Focus()
End If
Catch ex As Exception
MessageBox.Show("Failed to connect to Database", "Database Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
End
End Sub
End Class