Private子按钮2\u单击(ByVal sender作为System.Object,ByVal e作为System.EventArgs)处理按钮2。单击
列表框1.Items.Clear()
sql = "SELECT * FROM testing_mysql_vb"
Try
dbcomm = New MySqlCommand(sql, dbconn)
dbread = dbcomm.ExecuteReader()
While dbread.Read
ListBox1.Items.Add(dbread("product_name")("product_quantity"))
End While
dbread.Close()
Catch ex As Exception
MsgBox("Error in collecting data from Database. Error is :" & ex.Message)
dbread.Close()
Exit Sub
End Try
End Sub
End Class
我无法从数据库中获取数据
它表示从字符串转换为整数时出错
最佳答案
您正在将dbread("product_name")("product_quantity")
传递到ListBox.Items.Add
。那不管用。也许你想合并两列:
Dim prodNameVal As Object = dbread("product_name")
Dim productQuantityValue As Object = dbread("product_quantity")
ListBox1.Items.Add(String.Format("{0}: {1}", prodNameVal, productQuantityValue))
关于mysql - 从字符串转换为整数时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35629200/