Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Private Sub Login_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login.Enter
Dim strConnString As String
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\data_aeted.mdb;"
Dim con As New OleDbConnection(strConnString)
con.Open()
Try
If Username.Text <> "" Or Password.Text <> "" Then
Dim cm As New OleDbCommand("select Username,Password from table_log where Username='" & Username.Text & "' and Password='" & Password.Text & "'", con)
Dim Rd As OleDbDataReader
Dim userlogin, passlogin As String
Rd = cm.ExecuteReader
Rd.Read()
userlogin = Rd.Item("Username")
passlogin = Rd.Item("Password")
If Username.Text = userlogin And Password.Text = passlogin Then
MsgBox("ยินดีต้อนรับคุณ " & userlogin & "เข้าสู่ระบบครับ")
system2.Show() ' เขาเขียนแบบนีป่าวหวา<-------
End If
End If
con.Close()
If (Username.Text = "" And Password.Text = "") Then
MsgBox("ชื่อ Username หรือ Password ของท่านยังว่าอยู่ครับ")
Username.Focus()
Password.Focus()
Username.Clear()
Password.Clear()
End If
Catch ex As Exception
MsgBox("เสียใจ ไม่ให้เข้าระบบหรอก 5555 T-T")
Exit Sub
End Try
End Sub
End Class