Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
connn_start()
Dim Query As String
Query = "Select * from abc.abc_list"
Dim dbcomm = New MySqlCommand(Query, dbconn)
While dbread.Read 'error is throwing at this point
Dim DB_VName = dbread.GetString("abc_name")
cb_V_Name.Items.Add(DB_Name)
End While
Connn_stop()
Catch ex As MySqlException
MessageBox.Show(ex.Message)
Finally
dbconn.Dispose()
End Try
如何处理此异常?
答案 0 :(得分:0)
在阅读之前添加:
SqlDataReader dbread=dbcomm.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
...
}
}