如果在比较结束时没有从数据库中提取数据,我正在尝试显示一个消息框
Private Sub submitbutton_Click(sender As Object,
e As EventArgs) Handles submitbutton.Click myConnection.Open()
tutorboxr.Clear()
compboxr.Clear()
Dim str As String
Dim etr As String
str="SELECT * FROM 2014Results WHERE (Competitor = '" & Competitor.Text &"')"
etr="SELECT * FROM 2014Results WHERE (Event = '" & EventBox.Text &"')"
Dim cmd As OleDbCommand=New OleDbCommand(str,
myConnection)
Dim emd As OleDbCommand=New OleDbCommand(etr,
myConnection) dr=cmd.ExecuteReader
While dr.Read()
compboxr.Text=dr("Rank").ToString
textbox.Text=dr("Reg").ToString
If Competitor.Text="" Then MessageBox.Show("This student wasn't a ranking placeholder!",
MessageBoxButtons.OK,
MessageBoxIcon.Error)
End If
End While myConnection.Close()
If Competitor.Text="" Then MessageBox.Show("Please enter a students name",
"No entry",
MessageBoxButtons.OK,
MessageBoxIcon.Error) With Competitor .Focus() .SelectAll() End With Exit Sub
End If
End Sub
我收到此错误:
重载分辨率失败,因为在没有缩小转换的情况下无法调用可访问的“Show”::参数匹配参数从“MessageBoxButtons”缩小为“String”。 :参数匹配参数从'MessageBoxButtons'缩小。 :参数匹配参数从'String'缩小到。 :参数匹配参数'text'从'MessageBoxButtons'缩小为'String'。 :参数匹配参数从'String'缩小。
答案 0 :(得分:0)
看起来您在第一次MessageBox.Show
来电时缺少参数:
If Competitor.Text="" Then
MessageBox.Show("This student wasn't a ranking placeholder!",
MessageBoxButtons.OK,
MessageBoxIcon.Error)
End If
应该像第二个电话:
If Competitor.Text="" Then
MessageBox.Show("This student wasn't a ranking placeholder!",
"** a caption here **",
MessageBoxButtons.OK,
MessageBoxIcon.Error)
End If