Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. Inherits System.Windows.Forms.Form
  2. Dim mypath = Application.StartupPath & "\db1.accdb"
  3. Dim connection As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\db1.accdb;Persist Security Info=False;")
  4. Dim cmd As OleDbCommand
  5. Dim cmd2 As OleDbCommand
  6. Dim cmdGetIdentity = New OleDbCommand()
  7. Private WrongPassword As Integer = 0
  8. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  9. Dim sql = "SELECT username,password FROM admin WHERE username = '" & TextBox1.Text & "' AND password = '" & TextBox2.Text & "'"
  10. Dim Sql2 = "INSERT INTO audit (Date,login_time,username,accounttype) VALUES('" + DateTimePicker1.Text + "', '" + Label5.Text + "', '" + TextBox1.Text + "', '" + TextBox3.Text + "')"
  11. cmd = New OleDbCommand(sql, connection)
  12. cmd2 = New OleDbCommand(Sql2, connection)
  13. connection.Open()
  14. Dim affectedRecord As Integer
  15. Dim dr As OleDbDataReader = cmd.ExecuteReader
  16. Try
  17. connection.Open()
  18. affectedRecord = cmd2.ExecuteNonQuery()
  19. If affectedRecord = 0 Then
  20. MessageBox.Show("No Record was Updated")
  21. End If
  22.  
  23.  
  24. Catch ex As InvalidOperationException
  25.  
  26. End Try
  27.  
  28. Try
  29.  
  30. If dr.Read = False Then
  31. TextBox1.Text = ""
  32. TextBox2.Text = ""
  33. WrongPassword = WrongPassword + 1
  34. If WrongPassword = 1 Then
  35. MsgBox("WRONG PASSWORD", vbCritical, "LOGIN FAILED")
  36. MsgBox("You have 2 remaining chance to enter the correct password", vbCritical + vbOKOnly, "WARNING")
  37. ElseIf WrongPassword = 2 Then
  38. MsgBox("WRONG PASSWORD", vbCritical, "LOGIN FAILED")
  39. MsgBox("You have 1 remaining chance to enter the correct password", vbCritical + vbOKOnly, "WARNING")
  40. ElseIf WrongPassword = 3 Then
  41. MsgBox("WRONG PASSWORD", vbCritical, "LOGIN FAILED")
  42. MsgBox("SORRY! you reach 3 times attempt", vbCritical + vbOKOnly, "WARNING")
  43. Me.Close()
  44. End If
  45.  
  46. Else
  47. TextBox1.Clear()
  48. TextBox2.Clear()
  49. MsgBox("Login Successful", MsgBoxStyle.Information, "Administrator")
  50. mMenu.Show()
  51. Me.Hide()
  52. End If
  53.  
  54. Catch ex As Exception
  55.  
  56.  
  57. End Try
  58.  
  59. If connection.State <> ConnectionState.Closed Then
  60. connection.Close()
  61.  
  62. End If
  63. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement