If txtEmpID.Text.Trim() = "" Then
MessageBox.Show("กรุณากรอกรหัสพนักงานด้วยครับ", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
With sb
.Remove(0, sb.Length)
.Append("select EmpID,EmpName,EmpLastName from Employee")
.Append("where (EmpID LIKE '%" & txtEmpID.Text & "%')")
Dim SqlEmployee As String = sb.ToString()
Dim dtEmployee As DataTable
Dim com3 = Conn.CreateCommand()
With com3
.CommandType = CommandType.Text
.CommandText = SqlEmployee
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtEmployee = New DataTable
With dtEmployee
.Load(dr)
txtEmpID.Text = .Rows(0).Item("EmpID").ToString()
txtEmpName.Text = .Rows(0).Item("EmpName").ToString()
txtEmpLastName.Text = .Rows(0).Item("EmpLastName").ToString()
End With
txtPassWord.Focus()
Else
MessageBox.Show("ไม่มีรหัสพนักงาน", "Music Treading", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
txtEmpID.Focus()
End If
End With
End With
dr.Close()
End If
Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)