gpt4 book ai didi

mysql - 从字符串到整数的转换错误

转载 作者:行者123 更新时间:2023-11-29 06:16:31 25 4
gpt4 key购买 nike

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com