Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Pertam bikin tabel user di database
  2. bikin form Login
  3. Username: Label dan TextBox: name txtUsername
  4. Password: Label dan TextBox: name txtPassword, passwordChar isien (*)
  5. Button Login
  6.  
  7. Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
  8. Dim conn As MySqlConnection
  9. conn = New MySqlConnection
  10. conn.ConnectionString = "server=localhost; user id=root; password= ; database=program_rpl"
  11. Try
  12. conn.Open()
  13. Catch myerror As MySqlException
  14. MsgBox("Ada kesalahan dalam koneksi database")
  15. End Try
  16. Dim myAdapter As New MySqlDataAdapter
  17.  
  18. Dim sqlquery = "SELECT * FROM userWHERE Username = '" + txtUsername.Text + "' AND Password= '" + txtPassword.Text + "'"
  19. Dim myCommand As New MySqlCommand
  20. myCommand.Connection = conn
  21. myCommand.CommandText = sqlquery
  22.  
  23. myAdapter.SelectCommand = myCommand
  24. Dim myData As MySqlDataReader
  25. myData = myCommand.ExecuteReader()
  26.  
  27. If myData.HasRows = 0 Then
  28. MsgBox("Username atau Password ada yang salah !", MsgBoxStyle.Exclamation, "Error Login")
  29. Else
  30. MsgBox("Login Berhasil, Selamat Datang " & UsernameTextBox.Text & " ! ", MsgBoxStyle.Information, "Successfull Login")
  31. Form1.Show()
  32. Me.Hide()
  33. End If
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement