这是我的代码,但它显示错误,我不知道如何解决它:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("DBNewCode").Rows(inc).Item("NamEE") = TextBox1.Text
ds.Tables("DBNewCode").Rows(inc).Item(2) = TextBox2.Text
ds.Tables("DBNewCode").Rows(inc).Item(3) = TextBox3.Text
ds.Tables("DBNewCode").Rows(inc).Item(4) = TextBox4.Text
MessageBox.Show("Data updated")
da.Update(ds, "DBNewCode") // this is the error line
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbProvider = "PROVIDER=Microsoft.Jet.OLEDB.4.0;"
TheDatabase = "/DBNewCode.mdb"
MyDocumentsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
FullDatabasePath = MyDocumentsFolder & TheDatabase
dbSource = "Data Source = " & FullDatabasePath
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT * FROM TbNewCode"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "DBNewCode")
con.Close()
MaxRows = ds.Tables("DBNewCode").Rows.Count
inc = -1
End Sub
这是错误:
查询表达式中的语法错误(缺少运算符)'((No00 =?)AND ((?= 1 AND NamEE IS NULL)或(NamEE =?))AND((?= 1 AND IDDD IS NULL)OR(IDDD =?))AND((?= 1 AND位置IS NULL)OR(Location = ?))AND((?= 1 AND HP / EXT为空)或(HP / EXT =?))AND((?= 1 AND 投影机IS NULL)或(投影仪
有什么办法可以解决吗?我该怎么办?
答案 0 :(得分:0)
我想这与Access数据库中的字段名有关。 我相信你的字段名中有一个或多个包含数字和特殊字符的字段。不知何故VB / Access不喜欢包含数字的字段名称(也可能是特殊字符)。尝试将字段重命名为plain Alphabetic。认为这应该可以解决问题。