Guest User

user authentication

a guest
Mar 22nd, 2017
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Explicit
  2. Dim dbcon As New ADODB.Connection
  3. Dim rs As New ADODB.Recordset
  4.  
  5. Private Sub cmdCancel_Click()
  6.     End
  7. End Sub
  8.  
  9. Private Sub cmdOK_Click()
  10.     If txtUserName.Text = "" Then
  11.         MsgBox "Please enter username"
  12.         Exit Sub
  13.     End If
  14.     If txtPassword.Text = "" Then
  15.         MsgBox "please enter password"
  16.         Exit Sub
  17.     End If
  18.     If rs.State = 1 Then
  19.         rs.Close
  20.         Set rs = Nothing
  21.     End If
  22.     rs.Open "select * from login14yasb where username = '" & Trim(txtUserName.Text) & "' and password = '" & Trim(txtPassword.Text) & "'", dbcon, 1, 2
  23.     If rs.RecordCount > 0 Then
  24.         MsgBox "user credentials are authenticated successfully"
  25.     Else
  26.         MsgBox "Invalid credentials"
  27.     End If
  28. End Sub
  29.  
  30. Private Sub Form_Load()
  31.     dbcon.Open "libdsn", "scott", "tiger"
  32. End Sub
  33.  
  34. Private Sub Form_Unload(Cancel As Integer)
  35.     If dbcon.State = 1 Then
  36.          dbcon.Close
  37.         Set dbcon = Nothing
  38.     End If
  39. End Sub
  40.  
Add Comment
Please, Sign In to add comment