gpt4 book ai didi

vb.net - 查询表达式中的语法错误(逗号), header 带有逗号

转载 作者:行者123 更新时间:2023-12-03 08:22:40 25 4
gpt4 key购买 nike

我试图检查来自label1的值是否存在于名为“NALOG,C,8”的dbf文件列中。我无法更改DBF文件中的标题,因为它代表列的格式和字段大小。但是与此同时我得到了这个错误:“查询表达式” NALOG,C,8 = @NAL“中的语法错误(逗号)

这是完整的代码:

Dim con As New OleDbConnection
Dim cmd As New OleDbCommand

Dim FilePath As String = "C:\"
Dim DBF_File As String = "PROMGL"
Dim ColName As String = "NALOG,C,8"
'Dim SQLstr As String = "SELECT * FROM " & DBF_File
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath & _
" ;Extended Properties=dBASE IV;User ID=Admin;Password="
'cmd = New OleDbCommand("SELECT * FROM " & DBF_File)
cmd = New OleDbCommand("SELECT * FROM PROMGL WHERE " & ColName & " = @NAL")


cmd.Connection = con
con.Open()
cmd.Parameters.AddWithValue("@NAL", Label1.Text)
Using reader As OleDbDataReader = cmd.ExecuteReader()
If reader.HasRows Then
con.Close()
Label6.Text = "EXIST" & TextBox1.Text
TextBox1.Text = ""
TextBox1.Focus()

Else
Label6.Text = "DOESN'T EXIST"

End If
end using

谢谢。

最佳答案

如果您有一个名为以下的列:

Dim ColName As String = "NALOG,C,8"

然后我也将其更改为:
Dim ColName As String = "[NALOG,C,8]"

关于vb.net - 查询表达式中的语法错误(逗号), header 带有逗号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22935629/

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