我到处搜索,我仍然无法弄清楚这一点。每次打开表单时都会出现此错误,但程序会一直运行而没有任何问题。我已经发现错误是因为我在程序中添加了一个功能。当我从组合框中选择车辆ID代码时,文本框会自动显示车辆名称。这是错误的起源。
Private Sub ComboBox1_SelectedIndexChanged(sender as Object,e As EventArgs)处理ComboBox1.SelectedIndexChanged
Try
strsql = "SELECT nome FROM funcionarios where codfunc = " & Val(ComboBox1.Text) & ""
comando.CommandText = strsql
result = comando.ExecuteReader
bs.DataSource = result
tboxfunc.Text = bs.Current(0)
Catch erro As MySqlException
MessageBox.Show(erro.Message, "Erro do MySQL:",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Catch erro As Exception
MessageBox.Show(erro.Message, "Erro da Aplicação:",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
result.Close()
End Sub