我沃金与数据库中的项目,我想在我的表创建一个行,使用下面的查询:VB SQL错误:命令插入包含语法错误
"INSERT INTO USERCOINFO (username, company, streetAddress, postalCode, language, department, postOfficeBox, country, telephoneNumber, faxNumber, title, givenName, surname) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
该值可以用
Dim dbInsert As New OleDb.OleDbCommand
Dim objClient = GetObject(objRecordSet.Fields("ADsPath").Value)
Dim username = objRecordSet.Fields("Name").Value
Dim company = objClient.company
Dim streetAddress = objClient.streetAddress
Dim postalCode = objClient.postalCode
Dim lo = objClient.lo
Dim department = objClient.department
Dim postOfficeBox = objClient.postOfficeBox
Dim country = objClient.co
Dim telephoneNumber = objClient.telephoneNumber
Dim faxNumber = objClient.facsimiletelephonenumber
Dim title = objClient.title
Dim givenName = objClient.givenName
Dim surname = objClient.sn
以下变量填充,然后我将它们绑定:
dbInsert.Parameters.AddWithValue("@p1", username)
dbInsert.Parameters.AddWithValue("@p2", company)
'and so on...
我knownle GE,这是正确的,但它仍然会返回一个语法错误: The instruction INSERT contains a syntax error.
您需要在插入你的价值观部分帕拉姆名称。例如:'VALUES(@etc,@ etc2)'...现在你的查询不知道参数了......还要避免'AddWithValue'使用'Add'并指定SQL DataType ... – Codexer
@TimSchmelter对不起,我的不好,认为这是因为标题而引起的,我把它添加到了问题的底部 – Grey
@ Zaggler我已经为其他2个表做了这个,并且它可以工作,所以我不知道为什么这样做不会。 t这样工作 – Grey