Public Class frmLogin
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUserName.Text = "" Then
MsgBox("¡ÃسҡÃÍ¡User", vbOKOnly, "¡ÃسҡÃÍ¡¢éÍÁÙÅãËé¶Ù¡µéͧ")
txtUserName.Text = ""
txtUserName.Focus()
Exit Sub
ElseIf txtUserpass.Text = "" Then
MsgBox("¡ÃسҡÃÍ¡password", vbOKOnly, "¡ÃسҡÃÍ¡¢éÍÁÙÅãËé¶Ù¡µéͧ")
txtUserpass.Text = ""
txtUserpass.Focus()
Exit Sub
End If
Dim sqlStr As String
Dim conn As New ADODB.Connection
Dim sqlCm As New ADODB.Command
Dim rs As New ADODB.Recordset
sqlStr = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Port=3307;Database=vb_project;Uid=root;Pwd=admin;"
conn.ConnectionString = sqlStr
conn.Open()
With sqlCm
.ActiveConnection = conn
.CommandText = "Select * from User where USER_ID='" & txtUserName.Text & "' and PASSWORD= '" & txtUserpass.Text & "'"
.CommandType = ADODB.CommandTypeEnum.adCmdText
End With
With rs
.CursorType = ADODB.CursorTypeEnum.adOpenStatic
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.LockType = ADODB.LockTypeEnum.adLockOptimistic
.Open(sqlCm)
End With
If rs.RecordCount > 0 Then
frmMain.Show()
Me.Hide()
'ElseIf rs.RecordCount > 3 Then
' Me.Hide()
Else
MsgBox("", MsgBoxStyle.OkOnly, "")
End If
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
Application.Exit()
End Sub
End Class