0% found this document useful (0 votes)
19 views3 pages

VB.Net MySQL Login Form Code

The document describes a login form for an application that connects to a MySQL database. It includes code to connect to the database, validate login credentials against the database, and handle successful or failed login attempts by showing messages and navigating between forms. The form code handles logging in as an administrator or student user and refreshing or closing the form.

Uploaded by

D I M A S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

VB.Net MySQL Login Form Code

The document describes a login form for an application that connects to a MySQL database. It includes code to connect to the database, validate login credentials against the database, and handle successful or failed login attempts by showing messages and navigating between forms. The form code handles logging in as an administrator or student user and refreshing or closing the form.

Uploaded by

D I M A S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Imports [Link].

MySqlClient
Public Class Form1

Private Sub Form1_Load(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
Koneksi()
[Link] = 8
[Link] = "*"
[Link]()
[Link]()
End Sub

Private Sub btnlogin_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
If [Link] = "Administrator" Then

If [Link] = "" Or [Link] = "" Then


MsgBox("Data Belum Lengkap, Pastikan Semua Field Di Isi")
Exit Sub
Else
If [Link] = "" Then [Link]() : Exit Sub
If [Link] = "" Then [Link]() : Exit Sub
'perintah untuk mencari nama tertentu
cmd = New MySqlCommand
[Link] = conn
str = " SELECT username,password FROM login_siswa WHERE username=
'" & [Link] & "' AND password = '" & [Link] & "'"
[Link] = str

rd = [Link]

If [Link] Then
[Link]("Selamat Anda Berhasil Login", "Success",
[Link], [Link])
[Link]()
[Link]()
Else
'agar dapat mengulang ketika salah memasukkan username dan
password
[Link]()
[Link]()
[Link]("Login Gagal, Username dan Password Tidak
Sesuai", "Login Gagal", [Link], [Link])
'hapus semua field
[Link] = ""
[Link] = ""
'Focus di username
[Link]()
End If

End If
ElseIf [Link] = "Siswa" Then
If [Link] = "" Or [Link] = "" Then
MsgBox("Data Belum Lengkap, Pastikan Semua Field Di Isi")
Exit Sub
Else
If [Link] = "" Then [Link]() : Exit Sub
If [Link] = "" Then [Link]() : Exit Sub
cmd = New MySqlCommand
[Link] = conn
str = " SELECT username,password FROM login_siswa WHERE username=
'" & [Link] & "' AND password = '" & [Link] & "'"
[Link] = str

rd = [Link]

If [Link] Then
[Link]("Selamat Anda Berhasil Login", "Success",
[Link], [Link])
[Link]()
[Link]()
Else
'agar dapat mengulang ketika salah memasukkan username dan
password
[Link]()
[Link]()
[Link]("Login Gagal, Username dan Password Tidak
Sesuai", "Login Gagal", [Link], [Link])
'hapus semua field
[Link] = ""
[Link] = ""
'Focus di username
[Link]()
End If

End If
End If
End Sub

Private Sub btnrefresh_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link] = -1
[Link] = ""
[Link] = ""
End Sub

Private Sub btnkeluar_Click(ByVal sender As [Link], ByVal e As


[Link]) Handles [Link]
[Link]()
End Sub
End Class

Imports [Link]
Imports
Module Module1
'perintah yang akan di masukkan kedalan code form pemanggilan koneksi database
Public conn As MySqlConnection
Public cmd As MySqlCommand
Public rd As MySqlDataReader
Public da As MySqlDataAdapter
Public ds As DataSet
Public str As String
Public re As DataTableReader
Public cari As DataTable

'Koneksi [Link] Dengan Database Mysql


Sub Koneksi()
conn = New MySqlConnection
[Link] = "server=localhost;user
id=root;persistsecurityinfo=True;database=Login;port=3306;password="
Try
If [Link] = [Link] Then
[Link]()
End If
Catch ex As Exception
MsgBox("Koneksi Gagal" & [Link])
End Try
End Sub
End Module

You might also like