| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3433 人关注过本帖
标题:[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询 ...
只看楼主 加入收藏
LQJ267
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-6-16
结帖率:50%
收藏
已结贴  问题点数:5 回复次数:5 
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'id =' 中。
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/Connections/conn.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("id") <> "") Then
  Recordset1__MMColParam = Request.QueryString("id")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("")
Recordset1_cmd.ActiveConnection = MM_conn_STRING
Recordset1_ = "SELECT * FROM book WHERE id = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 5, 1, -1, Recordset1__MMColParam) ' adDouble

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>

<%

Set r2 = Server.CreateObject ("")
r2.ActiveConnection = MM_conn_STRING
 = "UPDATE book SET hits=hits+1 WHERE  id = "& request("id")

 = 1
 = 0
r2.Prepared = true
r2.Execute()
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.">
<html xmlns="http://www.">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言显示网页</title>
</head>

<body><table width="519" border="1">
<tr>
    <td width="73">编号</td>
    <td width="430"><%=(Recordset1.Fields.Item("id").Value)%></td>
  </tr>
  <tr>
    <td width="73">姓名</td>
    <td width="430"><%=(Recordset1.Fields.Item("name").Value)%></td>
  </tr>
  <tr>
    <td>性别</td>
    <td><%=(Recordset1.Fields.Item("sex").Value)%></td>
  </tr>
  <tr>
    <td>地址</td>
    <td><%=(Recordset1.Fields.Item("address").Value)%></td>
  </tr>
  <tr>
    <td>QQ</td>
    <td><%=(Recordset1.Fields.Item("qq").Value)%></td>
  </tr>
  <tr>
    <td>电话</td>
    <td><%=(Recordset1.Fields.Item("tel").Value)%></td>
  </tr>
  <tr>
    <td>查看次数</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>留言时间</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="164">留言内容</td>
    <td><%=(Recordset1.Fields.Item("message_board").Value)%></td>
  </tr>
</table>

</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
错误在这段里


<%

Set r2 = Server.CreateObject (")
r2.ActiveConnection = MM_conn_STRING
= "UPDATE book SET hits=hits+1 WHERE  id = "& request("id")

= 1
= 0
r2.Prepared = true
r2.Execute()
%>


大家看看是哪里错
搜索更多相关主题的帖子: 操作符 Microsoft ODBC Driver 语法 
2010-06-16 20:27
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
你这些是显示提交结果的页面,错误在提交页面不在显示页面
2010-06-16 21:56
LQJ267
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-6-16
收藏
得分:0 
程序代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/Connections/conn.asp" -->
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("")
Recordset1_cmd.ActiveConnection = MM_conn_STRING
Recordset1_ = "SELECT id, name, sex, tel, qq, email, message_board FROM book ORDER BY id DESC"
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 8
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
'  *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last

' set the record count
Recordset1_total = Recordset1.RecordCount

' set the number of rows displayed on this page
If (Recordset1_numRows < 0) Then
  Recordset1_numRows = Recordset1_total
Elseif (Recordset1_numRows = 0) Then
  Recordset1_numRows = 1
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last  = Recordset1_first + Recordset1_numRows - 1

' if we have the correct record count, check the other stats
If (Recordset1_total <> -1) Then
  If (Recordset1_first > Recordset1_total) Then
    Recordset1_first = Recordset1_total
  End If
  If (Recordset1_last > Recordset1_total) Then
    Recordset1_last = Recordset1_total
  End If
  If (Recordset1_numRows > Recordset1_total) Then
    Recordset1_numRows = Recordset1_total
  End If
End If
%>
<%
Dim MM_paramName
%>
<%
' *** Move To Record and Go To Record: declare variables

Dim MM_rs
Dim MM_rsCount
Dim MM_size
Dim MM_uniqueCol
Dim MM_offset
Dim MM_atTotal
Dim MM_paramIsDefined

Dim MM_param
Dim MM_index

Set MM_rs    = Recordset1
MM_rsCount   = Recordset1_total
MM_size      = Recordset1_numRows
MM_uniqueCol = ""
MM_paramName = ""
MM_offset = 0
MM_atTotal = false
MM_paramIsDefined = false
If (MM_paramName <> "") Then
  MM_paramIsDefined = (Request.QueryString(MM_paramName) <> "")
End If
%>
<%
' *** Move To Record: handle 'index' or 'offset' parameter

if (Not MM_paramIsDefined And MM_rsCount <> 0) then

  ' use index parameter if defined, otherwise use offset parameter
  MM_param = Request.QueryString("index")
  If (MM_param = "") Then
    MM_param = Request.QueryString("offset")
  End If
  If (MM_param <> "") Then
    MM_offset = Int(MM_param)
  End If

  ' if we have a record count, check if we are past the end of the recordset
  If (MM_rsCount <> -1) Then
    If (MM_offset >= MM_rsCount Or MM_offset = -1) Then  ' past end or move last
      If ((MM_rsCount Mod MM_size) > 0) Then         ' last page not a full repeat region
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While ((Not MM_rs.EOF) And (MM_index < MM_offset Or MM_offset = -1))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
  If (MM_rs.EOF) Then
    MM_offset = MM_index  ' set MM_offset to the last possible record
  End If

End If
%>
<%
' *** Move To Record: if we dont know the record count, check the display range

If (MM_rsCount = -1) Then

  ' walk to the end of the display range for this page
  MM_index = MM_offset
  While (Not MM_rs.EOF And (MM_size < 0 Or MM_index < MM_offset + MM_size))
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend

  ' if we walked off the end of the recordset, set MM_rsCount and MM_size
  If (MM_rs.EOF) Then
    MM_rsCount = MM_index
    If (MM_size < 0 Or MM_size > MM_rsCount) Then
      MM_size = MM_rsCount
    End If
  End If

  ' if we walked off the end, set the offset based on page size
  If (MM_rs.EOF And Not MM_paramIsDefined) Then
    If (MM_offset > MM_rsCount - MM_size Or MM_offset = -1) Then
      If ((MM_rsCount Mod MM_size) > 0) Then
        MM_offset = MM_rsCount - (MM_rsCount Mod MM_size)
      Else
        MM_offset = MM_rsCount - MM_size
      End If
    End If
  End If

  ' reset the cursor to the beginning
  If (MM_rs.CursorType > 0) Then
    MM_rs.MoveFirst
  Else
    MM_rs.Requery
  End If

  ' move the cursor to the selected record
  MM_index = 0
  While (Not MM_rs.EOF And MM_index < MM_offset)
    MM_rs.MoveNext
    MM_index = MM_index + 1
  Wend
End If
%>
<%
' *** Move To Record: update recordset stats

' set the first and last displayed record
Recordset1_first = MM_offset + 1
Recordset1_last  = MM_offset + MM_size

If (MM_rsCount <> -1) Then
  If (Recordset1_first > MM_rsCount) Then
    Recordset1_first = MM_rsCount
  End If
  If (Recordset1_last > MM_rsCount) Then
    Recordset1_last = MM_rsCount
  End If
End If

' set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_rsCount <> -1 And MM_offset + MM_size >= MM_rsCount)
%>
<%
' *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters

Dim MM_keepNone
Dim MM_keepURL
Dim MM_keepForm
Dim MM_keepBoth

Dim MM_removeList
Dim MM_item
Dim MM_nextItem

' create the list of parameters which should not be maintained
MM_removeList = "&index="
If (MM_paramName <> "") Then
  MM_removeList = MM_removeList & "&" & MM_paramName & "="
End If

MM_keepURL=""
MM_keepForm=""
MM_keepBoth=""
MM_keepNone=""

' add the URL parameters to the MM_keepURL string
For Each MM_item In Request.QueryString
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepURL = MM_keepURL & MM_nextItem & Server.URLencode(Request.QueryString(MM_item))
  End If
Next

' add the Form variables to the MM_keepForm string
For Each MM_item In Request.Form
  MM_nextItem = "&" & MM_item & "="
  If (InStr(1,MM_removeList,MM_nextItem,1) = 0) Then
    MM_keepForm = MM_keepForm & MM_nextItem & Server.URLencode(Request.Form(MM_item))
  End If
Next

' create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL & MM_keepForm
If (MM_keepBoth <> "") Then
  MM_keepBoth = Right(MM_keepBoth, Len(MM_keepBoth) - 1)
End If
If (MM_keepURL <> "")  Then
  MM_keepURL  = Right(MM_keepURL, Len(MM_keepURL) - 1)
End If
If (MM_keepForm <> "") Then
  MM_keepForm = Right(MM_keepForm, Len(MM_keepForm) - 1)
End If

' a utility function used for adding additional parameters to these strings
Function MM_joinChar(firstItem)
  If (firstItem <> "") Then
    MM_joinChar = "&"
  Else
    MM_joinChar = ""
  End If
End Function
%>
<%
' *** Move To Record: set the strings for the first, last, next, and previous links

Dim MM_keepMove
Dim MM_moveParam
Dim MM_moveFirst
Dim MM_moveLast
Dim MM_moveNext
Dim MM_movePrev

Dim MM_urlStr
Dim MM_paramList
Dim MM_paramIndex
Dim MM_nextParam

MM_keepMove = MM_keepBoth
MM_moveParam = "index"

' if the page has a repeated region, remove 'offset' from the maintained parameters
If (MM_size > 1) Then
  MM_moveParam = "offset"
  If (MM_keepMove <> "") Then
    MM_paramList = Split(MM_keepMove, "&")
    MM_keepMove = ""
    For MM_paramIndex = 0 To UBound(MM_paramList)
      MM_nextParam = Left(MM_paramList(MM_paramIndex), InStr(MM_paramList(MM_paramIndex),"=") - 1)
      If (StrComp(MM_nextParam,MM_moveParam,1) <> 0) Then
        MM_keepMove = MM_keepMove & "&" & MM_paramList(MM_paramIndex)
      End If
    Next
    If (MM_keepMove <> "") Then
      MM_keepMove = Right(MM_keepMove, Len(MM_keepMove) - 1)
    End If
  End If
End If

' set the strings for the move to links
If (MM_keepMove <> "") Then
  MM_keepMove = Server.HTMLEncode(MM_keepMove) & "&"
End If

MM_urlStr = Request.ServerVariables("URL") & "?" & MM_keepMove & MM_moveParam & "="

MM_moveFirst = MM_urlStr & "0"
MM_moveLast  = MM_urlStr & "-1"
MM_moveNext  = MM_urlStr & CStr(MM_offset + MM_size)
If (MM_offset - MM_size < 0) Then
  MM_movePrev = MM_urlStr & "0"
Else
  MM_movePrev = MM_urlStr & CStr(MM_offset - MM_size)
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.">
<html xmlns="http://www.">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言列表主页</title>
</head>

<body>
<table width="600" border="1" align="center">
  <tr>
    <td>id</td>
    <td>姓名</td>
    <td>性别</td>
    <td>电话</td>
    <td>qq</td>
    <td>email</td>
    <td>留言板</td>
  </tr>
  <% While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) %>
    <tr>
      <td><%=(Recordset1.Fields.Item("id").Value)%></td>
      <td><%=(Recordset1.Fields.Item("name").Value)%></td>
      <td><%=(Recordset1.Fields.Item("sex").Value)%></td>
      <td><%=(Recordset1.Fields.Item("tel").Value)%></td>
      <td><%=(Recordset1.Fields.Item("qq").Value)%></td>
      <td><%=(Recordset1.Fields.Item("email").Value)%></td>
      <td nowrap="nowrap"><a href="show.asp?id=<%=(Recordset1.Fields.Item("id").Value)%>" target=_blank><%=(Recordset1.Fields.Item("message_board").Value)%></a>
                   <!-- 生成网页链接-->
      </td>
    </tr>
    <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
</table>

<table width="600" border="0" align="center">
  <tr>
    <td><% If MM_offset <> 0 Then %>
          <a href="<%=MM_moveFirst%>">第一页</a>          <!--判断当前页数据生成翻页链接-->
          <% End If ' end MM_offset <> 0 %>
    </td>
    <td><% If MM_offset <> 0 Then %>
          <a href="<%=MM_movePrev%>">上一页</a>            <!--上一页链接-->
          <% End If ' end MM_offset <> 0 %>
    </td>
    <td><% If Not MM_atTotal Then %>
          <a href="<%=MM_moveNext%>">下一页</a>                 <!--下一页链接-->
          <% End If ' end Not MM_atTotal %>
    </td>
    <td><% If Not MM_atTotal Then %>
          <a href="<%=MM_moveLast%>">最后一页</a>                 <!--末页链接-->
          <% End If ' end Not MM_atTotal %>
    </td>
  </tr>
</table>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>



这是提交页面,大哥你看看 十分感谢!
2010-06-17 13:49
冰镇柠檬汁儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:北京
等 级:版主
威 望:120
帖 子:8078
专家分:6657
注 册:2005-11-7
收藏
得分:5 
"><a href="show.asp?id=<%=(Recordset1.Fields.Item("id").Value)%>"
把这段代码换成
"><a href="show.asp?id=<%=(Recordset1("id")%>" 试试,
难道说asp升级了

楼主,你的这篇帖子应该发到asp区,这里不是,要不要我帮你转过去呀

本来无一物,何处惹尘埃
It is empty at all here, Why pm 2.5 is so TMD high!
2010-06-17 17:13
saitor
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
威 望:5
帖 子:373
专家分:1520
注 册:2009-5-18
收藏
得分:0 
这语言我是不懂,不过request("id")出来的应该是OBJECT吧,还是这语言会自己转INT?
2010-06-17 21:43
LQJ267
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2010-6-16
收藏
得分:0 
  谢谢4楼
2010-06-17 22:12
快速回复:[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042747 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved