我正在尝试显示“找不到记录”消息框,但我不知道如何编写代码。我有一个搜索框,如果在用户搜索时找到了他们的记录,我想创建一个消息框。
Private Sub Search2ToolStripButton_Click(sender As Object, e As EventArgs) Handles Search2ToolStripButton.Click
Try
Me.StaffTableAdapter.Search2(Me.Semester2DataSet.Staff, FirstNameToolStripTextBox.Text, SurnameToolStripTextBox.Text)
'rather than crash the system, in the case of an error...
Catch ex As System.Exception
'A message box will appear telling the user of the error.
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
Search2是我从DataSet创建的查询
SELECT StaffID, AddressID, FirstName, Surname, Occupation, [Mobile Number], [Contract Start], [Contract End] FROM Staff
WHERE (FirstName LIKE?) AND (Surname LIKE?)