Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If TextBox1.Text.Trim() = "" Then
Return
End If
If e.KeyCode = Keys.Enter Then
sb.Remove(0, sb.Length)
sb.Append("SELECT id_member,name_member")
sb.Append("FROM member")
sb.Append("WHERE (id_member=@id_member)")
Dim sqlmember As String = sb.ToString()
Dim dtMember As DataTable
com.CommandType = CommandType.Text
com.CommandText = sqlmember
com.Parameters.Clear()
com.Parameters.Add("@id_member", MySqlDbType.VarChar).Value = TextBox1.Text.Trim()
com.Connection = Conn
dr = com.ExecuteReader '******* มันแจ้งตรงส่วนนี้มาอะครับ *******
If dr.HasRows Then
dtMember = New DataTable
dtMember.Load(dr)
TextBox1.Text = dtMember.Rows(0)("id_member").ToString()
TextBox3.Text = dtMember.Rows(0)("name_member").ToString()
TextBox3.Focus()
Else
MessageBox.Show("รหัสสมาชิกที่คุณป้อน ไม่มีในระบบ", "ระบบตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Information)
ClearMemberData()
TextBox1.Focus()
End If
dr.Close()
End If
End Sub