Imports MySql.Data.MySqlClient
Public Class Login
Dim cmd As New MySql.Data.MySqlClient.MySqlCommand
Dim dt As DataTable
Dim sql As String
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Call konek()
cmd.Connection = conn
cmd.CommandType = CommandType.Text
Dim MyAdapter As New MySqlDataAdapter
Dim sqlquery = "SELECT u.nama, u.passwd " & _
" FROM user as u" & _
" WHERE " & _
" nama = '" & TextBox1.Text & "' " & _
" AND passwd = '" & TextBox2.Text & "' "
cmd.Connection = conn
cmd.CommandText = sqlquery
MyAdapter.SelectCommand = cmd
Dim MyData As MySqlDataReader
MyData = cmd.ExecuteReader()
conn.Close()
If MyData.HasRows = 0 Then
MsgBox("Mohon periksa nama dan password ANDA!", MsgBoxStyle.Exclamation, "Error Login")
Else
Loading.Show()
Me.Hide()
End If
Catch ex As Exception
MsgBox("Ada Kesalahan Login", MsgBoxStyle.MsgBoxRight, "Message")
MsgBox("Error :" & ex.Message, MsgBoxStyle.Exclamation)
End Try
conn.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
daftar.Show()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class