gpt4 book ai didi

mysql select语句未填充数据表

转载 作者:行者123 更新时间:2023-11-29 08:12:56 25 4
gpt4 key购买 nike

我有一个 MySQL 对象,我试图从中选择所有数据并将其插入到数据表中,但是每次它到达有关所述数据表的第一个 if 语句时,它都会出现可能的空值错误

dbfile dbserver dbuser 和 dbpassw 都是在模块上设置的公共(public)变量。

可变尺寸

Dim cnn As New MySqlConnection()
Dim cmd As New MySqlCommand
Dim adptr As New MySqlDataAdapter
Dim filltab As DataTable

代码

        Dim cb As New MySqlConnectionStringBuilder
cb.Database = dbfile
cb.Server = dbserver
cb.UserID = dbuser
cb.Password = dbpassw
Using cnn As New MySqlConnection(cb.ConnectionString)
Using cmd As New MySqlCommand("SELECT * from gpstracking", cnn)
Try
cnn.Open()
adptr = New MySqlDataAdapter(cmd)
adptr.Fill(filltab)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
If filltab.Rows.Count > 0 Then 'this is the row that the error for filltab being a null value hits
pop = 0

For pop As Integer = 0 To filltab.Rows.Count - 1
' WebBrowser1.Document.InvokeScript("AddMarker", New Object() {"Unit: " & filltab.Rows(pop)("unitnumb") & " at " & filltab.Rows(pop)("time"), filltab.Rows(pop)("lat"), table.Rows(pop)("long")})
Next
End If
End Using
End Using

有一个错误

adptr.Fill(filltab)  'Exception:Thrown: "Value cannot be null." (System.ArgumentNullException)

我还刚刚注意到它在

上宣布“无法收集详细信息”
            Catch ex As Exception
MsgBox(ex.ToString)
End Try

最佳答案

我不知道vb语法,但你有Dim filltab As DataTable,没有New(就像在其他维度中一样),我猜MySqlDataAdapter.Fill 要求参数不为空。只是猜测。

关于mysql select语句未填充数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21208893/

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