Private Sub Login_Click()
userid.SetFocus
If userid.Text = "" Then
MsgBox "", vbOKOnly, ""
userid.Text = ""
userid.SetFocus
Exit Sub
End If
If user_pass.Text = "" Then
MsgBox "", vbOKOnly, ""
user_pass.Text = ""
user_pass.SetFocus
Exit Sub
End If
If Len(user_pass.Text) < 5 Then
MsgBox "", vbOKOnly, ""
user_pass.Text = ""
user_pass.SetFocus
Exit Sub
End If
'?????? SQL Statement
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='" & userid.Text & "' and PASSWORD= '" & user_pass.Text & "'"
.CommandType = adCmdText
End With
With rs
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open sqlCm
End With
If rs.RecordCount > 0 Then
Form_Cus.Show
Else
MsgBox "User Name or Password is not correct", vbCritical, Error
End If
End Sub