Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. Imports System.Data.SqlClient
  2. Imports MySql.Data.MySqlClient
  3. Public Class Login
  4. Dim MySqlConnection As MySqlConnection
  5. Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
  6. MySqlConnection = New MySqlConnection
  7. MySqlConnection.ConnectionString = "server=localhost; port=3306; user id=root; password=; database=program;"
  8. MySqlConnection.Open()
  9. Dim Myadapter As New MySqlDataAdapter()
  10. Dim Command As New MySqlCommand
  11. Command.Connection = MySqlConnection
  12. Command.CommandText = "SELECT * FROM users WHERE username='" & UsernameTextBox.Text & "'AND password='" & PasswordTextBox.Text & "'"
  13. Myadapter.SelectCommand = Command
  14. Dim myData As MySqlDataReader
  15. myData = Command.ExecuteReader
  16. If myData.HasRows = 0 Then
  17. MsgBox("Error Wrong Login Info!")
  18. Else
  19. Form1.Show()
  20. Me.Close()
  21.  
  22. End If
  23. End Sub
  24.  
  25. Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
  26. Me.Close()
  27. End Sub
  28.  
  29.  
  30. Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  31.  
  32. End Sub
  33.  
  34. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement