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

sql提示:语法错误 (操作符丢失) 在查询表达式 '[id]<7order by [id] desc' 中。

zmhdxy 发布于 2007-12-25 16:18, 824 次点击
<%
    dim vid,action
    vid=cint(request.QueryString("id"))
    dim conn
    set conn = server.CreateObject("ADODB.Connection")
    conn.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("photo.mdb")
    conn.open
    dim strsql
    if request("action")="left" then
    strsql="select  TOP 1 * from photo where [id]<" & vid & "order by [id] desc"
    elseif request("action")="right" then
    strsql="select  TOP 1 * from photo where [id]>" & vid &"order by [id] asc"
    else
    strsql="select * from photo where id=" & vid
    end if
    dim rs
    set rs = server.CreateObject("ADODB.RecordSet")
    rs.open strsql,conn,3
    If rs.EOF Then
    Response.Write "<script type='text/javascript'>alert('对不起,您越界了!');window.history.go(-1);</script>"
    rs.Close
    Set rs = Nothing
    conn.Close
    Set rs = Nothing
    Response.End
End If
%>
达到的功能是浏览图片,通过点击图片按钮,进行察看
3 回复
#2
hangxj2007-12-25 17:21
strsql="select  TOP 1 * from photo where [id]<" & vid & "order by [id] desc"
    elseif request("action")="right" then
    strsql="select  TOP 1 * from photo where [id]>" & vid &"order by [id] asc"

" & vid & "order

中间的空格你没有~~~
书写的时候没有认真查看~~
#3
zmhdxy2007-12-25 18:43
就是这个错误
太谢谢了
#4
zmhdxy2007-12-25 18:45
strsql="select  TOP 1 * from photo where [id]<" & vid & " order by [id] desc"
    elseif request("action")="right" then
    strsql="select  TOP 1 * from photo where [id]>" & vid &" order by [id] asc"
有图像的地方是空格 不能少
1