Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Pertam bikin tabel user di database
- bikin form Login
- Username: Label dan TextBox: name txtUsername
- Password: Label dan TextBox: name txtPassword, passwordChar isien (*)
- Button Login
- Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
- Dim conn As MySqlConnection
- conn = New MySqlConnection
- conn.ConnectionString = "server=localhost; user id=root; password= ; database=program_rpl"
- Try
- conn.Open()
- Catch myerror As MySqlException
- MsgBox("Ada kesalahan dalam koneksi database")
- End Try
- Dim myAdapter As New MySqlDataAdapter
- Dim sqlquery = "SELECT * FROM userWHERE Username = '" + txtUsername.Text + "' AND Password= '" + txtPassword.Text + "'"
- Dim myCommand As New MySqlCommand
- myCommand.Connection = conn
- myCommand.CommandText = sqlquery
- myAdapter.SelectCommand = myCommand
- Dim myData As MySqlDataReader
- myData = myCommand.ExecuteReader()
- If myData.HasRows = 0 Then
- MsgBox("Username atau Password ada yang salah !", MsgBoxStyle.Exclamation, "Error Login")
- Else
- MsgBox("Login Berhasil, Selamat Datang " & UsernameTextBox.Text & " ! ", MsgBoxStyle.Information, "Successfull Login")
- Form1.Show()
- Me.Hide()
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement