【发布时间】:2015-10-09 23:48:52
【问题描述】:
With cmd
.Connection = con
.CommandTimeout = 0
.CommandText = "INSERT INTO tableContacts (NameUser, Address, City, Phone, Fax, Note, Email) VALUES (@NameUser, @Address, @City, @Phone, @Fax, @Note, @Email)"
With .Parameters
.AddWithValue("@NameUser", txtName.Text)
.AddWithValue("@Address", txtAddress.Text)
.AddWithValue("@City", txtCity.Text)
.AddWithValue("@Phone", txtPhone.Text)
.AddWithValue("@Fax", txtFax)
.AddWithValue("@Note", txtNote.Text)
.AddWithValue("@Email", txtTo.Text)
End With
Try
cmd.ExecuteNonQuery()
Catch ex As Exception
End Try
.Dispose()
End With
找不到问题出在哪里。
调试器说的是:
{"INSERT INTO 语句中的语法错误。"}
【问题讨论】:
-
这与@Email 无关,这是访问数据库
-
对于那些投票关闭作为“错字问题”并支持相应 cmets 的人:如果它是关于缺少/无效的参数,则错误会有所不同。
-
Note是保留字。您需要将其括在方括号[Note]中。 support.microsoft.com/en-us/kb/321266 -
@GSerg 我投票关闭它作为一个错字。我们不需要对每个保留字进行问答。如果您知道一个好的规范,请将 VTC 作为骗子。
-
@Bjørn-RogerKringsjå 好的,如果您 VTC 知道它与关键字有关,那是有道理的。接近投票出现在您的评论之前,因此看起来人们正在根据缺少的
@进行 VTC。