注册 登录
编程论坛 ASP技术论坛

sql 中的where问题

zmhdxy 发布于 2007-12-02 01:02, 673 次点击
sql="update Diary set replynumber=replynumber+1 where Title="&tx1&"and Reply='主题'"
提示错误
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'Title=zxZand Reply='主题'' 中。
肯定的是tx1是有值的 而且是正确的 Reply也是对的
7 回复
#2
madpbpl2007-12-02 03:14
数据类型可能不对,title是文本类型吗?
title是文本类型,则改成,主题后面少了一个“'”
sql="update Diary set replynumber=replynumber+1 where Title='" & tx1 & "' and Reply='主题'"

[[italic] 本帖最后由 madpbpl 于 2007-12-3 02:49 编辑 [/italic]]
#3
zmhdxy2007-12-02 11:52
这样也是可以的
sql="update Diary set replynumber=replynumber+1 where (Title='"&tx1&"')and (Reply='主题')"
#4
zmhdxy2007-12-02 11:57
楼上的 我总觉的这个不对啊
Title=''" & tx1 & "' and Reply='主题'''
应该是Title=''" & tx1 & "' and Reply='主题'
可能是你不小心
#5
madpbpl2007-12-03 02:48
原帖由 [bold][underline]zmhdxy[/underline][/bold] 于 2007-12-2 11:57 发表 [url=http://bbs.bc-cn.net/redirect.php?goto=findpost&pid=1126678&ptid=189823][/url]
楼上的 我总觉的这个不对啊
Title=''" & tx1 & "' and Reply='主题'''
应该是Title=''" & tx1 & "' and Reply='主题'
可能是你不小心

不好意思,新改版的论坛,写了单引号,双引号,看的不清楚,手误,我把楼上调整一下。
#6
xiang5882007-12-03 09:51
字符串需要用' '引起来
and前面还要有个空格
#7
zmhdxy2007-12-03 18:49
我也写错了
应该是
Title=' " & tx1 & "'  and  Reply='主题'
#8
zmhdxy2007-12-04 10:03
问题解决
1