3086错误无法从指定的表中删除

时间:2016-06-08 14:02:19

标签: sql-server ms-access-2010

当我从sql server数据库中的ms访问表单中删除记录并且表通过odbc连接和vb.net中写入的删除命令链接时,我收到此错误,请任何人向我显示此命令行的解决方案,如下所示< / p>

DoCmd.RunSQL "Delete  from dbo_Main where user =  Forms![frm-Examiner]![coUser] "

感谢 拉梅什

3 个答案:

答案 0 :(得分:1)

如果它不是权限问题,您可以尝试这样做:

dim sSql as string
sSql = "Delete from dbo_Main where user = '" & Forms![frm-Examiner]![coUser] & "'"
debug.print sSql
DoCmd.RunSQL sSql

至少应该给你一些关于可能出错的提示

答案 1 :(得分:1)

用户是reserved word。将其括在方括号中以确保db引擎将其视为字段名称。

DoCmd.RunSQL "Delete from dbo_Main where [user] = Forms![frm-Examiner]![coUser] "

答案 2 :(得分:0)

结合@HansUp和@iDevlop

的建议
dim sSql as string
sSql = "Delete from dbo_Main where [user] = '" & Forms![frm-Examiner]![coUser] & "'"
DoCmd.RunSQL sSql