Dim fdCon As New MySqlConnection("Database=stok;Data Source=localhost;User Id=root;Password=root")
Dim fdCom As New MySqlCommand(" ", fdCon)
fdCon.Open()
Dim cmd As MySqlCommand
Dim sql As String
Dim num_Rec As Integer
Dim dr = cmd.ExecuteReader
sql = "select * from user where id='" & TextBox1.Text & "' and Pass='" & TextBox2.Text & "'"
cmd = New MySqlCommand(sql, fdCon)
dr = cmd.ExecuteReader
num_Rec = 0
While dr.Read
num_Rec = num_Rec + 1
MsgBox("ยินดีต้อนรับเข้าสู่ระบบคลังสินค้าผงซักฟอก")
End While
If num_Rec > 0 Then
Me.Hide()
Form2.Show()
Else
TextBox1.Text = ""
TextBox2.Text = ""
MsgBox("ไม่สามารถเข้าสู่ระบบได้")
End If (VB.NET)