ASP错误 '80040e14‘ UPDATE 语句的语法错误

December 14, 2010 | tags ASP知识  网页编程   | views
Comments 1
ASP错误 '80040e14‘ UPDATE 语句的语法错误
---
来源:TTT BLOG [ http://www.taoyoyo.net/ttt/ ]
地址:http://www.taoyoyo.net/ttt/post/504.html
---

刚才整理了一下友情链接页面,添加了管理密码。无意中发现修改页面不能正常保存,报错如下:

Microsoft JET Database Engine 错误 '80040e14

UPDATE 语句的语法错误

……

检查代码中sql语句,没有问题啊。

pSql="update Resource set User_ID ='" & pUserID & "', Status='" & pStatus & "',SortI='" & pSortI & "',SortII='" & pSortII & "', Name='" & pName & "', Address='" & pAddress & "',Image='" & pImage & "',Width='" & pWidth & "',Height='" & pHeight & "',Owner='" & pOwner & "',Author1='" & pAuthor1 & "',Author2='" & pAuthor2 & "',Author3='" & pAuthor3 & "',Email='" & pEmail & "',Homepage='" & pHomepage & "',Special='" & pSpecial & "',Description='" & pDescription & "',Recommend='" & pRecommend & "',Remark='" & pRemark & "',UpdataUser='" & pUser & "', UpdataDate='" & pDateTime & "' where ID=" & pID

又将SQL语句在网页中显示,复制到数据库中执行,没有问题。

update Resource set User_ID ='TAL', Status='A',SortI='网站',SortII='IT', Name='秀客网', Address='http://www.picook.com/',Image='http://picook.com/Picook.asp?pID=2362',Width='',Height='',Owner='',Author1='',Author2='',Author3='',Email='ssssssss',Homepage='http://www.picook.com/',Remark='',UpdataUser='00000', UpdataDate='20101214094733' where ID=166

真是奇怪,偏偏还没有别的提示,只是说语法错误……

在网上搜了一下,终于找到解决办法:

Microsoft JET Database Engine 错误 '80040e14' UPDATE 语句的语法错误。 

有代码如: 

Update 表 set action="值" where id=值 

发现在action用作字段有问题,不知是否与关键字冲突,改为: 

Update 表 set [action]="值" where id=值 

问题解决!

按此方法,将sql中的字段加上方括号:

pSql="update Resource set [User_ID] ='" & pUserID & "', [Status]='" & pStatus & "',[SortI]='" & pSortI & "',[SortII]='" & pSortII & "', [Name]='" & pName & "', [Address]='" & pAddress & "',[Image]='" & pImage & "',[Width]='" & pWidth & "',[Height]='" & pHeight & "',[Owner]='" & pOwner & "',[Author1]='" & pAuthor1 & "',[Author2]='" & pAuthor2 & "',[Author3]='" & pAuthor3 & "',[Email]='" & pEmail & "',[Homepage]='" & pHomepage & "',[Special]='" & pSpecial & "',[Description]='" & pDescription & "',[Recommend]='" & pRecommend & "',[Remark]='" & pRemark & "',[UpdataUser]='" & pUser & "', [UpdataDate]='" & pDateTime & "' where [ID]=" & pID

果然,问题解决了!

其实在access中用查询视图生成的sql请语句中的字段都是带方括号的,但有时手写不带也可以,所以一般时候都不带,没想到这次碰到问题了!

--本文来源于[TTT BLOG]:http://www.taoyoyo.net/ttt/post/504.html
(提示:转载时请务必保留此版权信息或者注明来源。)



  • quote 1.ww.ytzx.net
  • http://ww.ytzx.net
  • 好复杂的sql语句
    tao 于 2011-10-18 14:33:39 回复
    呵呵,其实并不复杂了,就是一个更新语句,可能更新的字段多了些,而且是用代码合成的,所以显得挺乱的。
  • 2011-9-24 8:04:37 回复该留言


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。