Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. Imports System.Data.OleDb
  2.  
  3. Public Class AdminLogin
  4. Inherits System.Windows.Forms.Form
  5. Dim mypath = Application.StartupPath & "\NSDAPS.mdb"
  6. Dim connection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\NSDAPS.mdb;")
  7. Dim cmd As OleDbCommand
  8.  
  9. Private Sub AdminLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  10.  
  11. End Sub
  12.  
  13.  
  14.  
  15. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  16. Dim sql = "SELECT Username,Password FROM Admin_Account WHERE Username = '" & TextBox1.Text & "' AND Password = '" & TextBox2.Text & "'"
  17. cmd = New OleDbCommand(sql, connection)
  18. connection.Open()
  19. Dim dr As OleDbDataReader = cmd.ExecuteReader
  20.  
  21. Try
  22. connection.Open()
  23.  
  24. Catch ex As InvalidOperationException
  25.  
  26. End Try
  27.  
  28. Try
  29.  
  30. If dr.Read = False Then
  31. MsgBox("Login Failed", MsgBoxStyle.Critical, "ADMIN")
  32. TextBox1.Text = ""
  33. TextBox2.Text = ""
  34.  
  35. Else
  36. MsgBox("Login Successful", MsgBoxStyle.Information, "ADMIN")
  37. AdminMenu.Show()
  38. Me.Hide()
  39. End If
  40.  
  41. Catch ex As Exception
  42.  
  43.  
  44. End Try
  45.  
  46. If connection.State <> ConnectionState.Closed Then
  47. connection.Close()
  48.  
  49. End If
  50. End Sub
  51.  
  52. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  53. End
  54. End Sub
  55. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement