回 帖 发 新 帖 刷新版面

主题:[讨论]ASP建站中使用嵌套重复区域后预览错误

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 该特定字段 'vote_id' 可以参考 SQL 语句中 FROM 子句列表中的多个表。
/yidais/VoteSystem/huizong.asp, 第 97 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) 

网页:
GET /yidais/VoteSystem/huizong.asp 

时间:
2009年2月24日, 10:25:12 


详细信息:
Microsoft 支持 

huizong.asp代码如下:


<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/votesystemconn.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_votesystemconn_STRING
Recordset1.Source = "SELECT * FROM voteTopic ORDER BY vote_id DESC"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_votesystemconn_STRING
Recordset2.Source = "SELECT votecontent.votecontent_id,votecontent.vote_ID,  votecontent.vote_content,votetopic.vote_ID  FROM voteContent,votetopic  WHERE votecontent.vote_ID = votetopic.vote_ID  ORDER BY votecontent.votecontent_id ASC"
Recordset2.CursorType = 0
Recordset2.CursorLocation = 2
Recordset2.LockType = 1
Recordset2.Open()

Recordset2_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
'JomoWeb c2001 nstrpt1
function JomoPrefix(rs, fldName)
dim str, strlen, whereloc, orderloc
str = rs.source
strlen = Len(str)
whereloc=InStr(str," WHERE ")
orderloc=InStr(str," ORDER BY ")
if orderloc = 0 and whereloc = 0 then 
  JomoPrefix = str & " WHERE " & fldName & " = "
else
  if whereloc = 0 then
      JomoPrefix=Left(str,orderloc) & " WHERE " & fldName & " = "
  else
      if orderloc = 0 then orderloc = strlen
      JomoPrefix=Left(str,whereloc+6) &" ( " &  Mid(str, whereloc+7, orderloc - whereloc -6 ) & " )  AND " & fldName & " = "
  end if
end if
end function

function JomoPostfix(rs)
dim str, orderloc
str=rs.source
orderloc = InStr(str," ORDER BY ")
if orderloc = 0 then
  JomoPostfix = ""
else
JomoPostfix = " " & right(str, Len(str) - orderloc)
end if
end function
 %>
<% 
'JomoWeb c2001 nstrpt2
dim Recordset2_prefix, Recordset2_postfix
Recordset2_prefix = JomoPrefix(Recordset2, "vote_id")
Recordset2_postfix=JomoPostfix(Recordset2)
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<% 
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
%>
  <table width="100%" border="0">
    <tr>
      <td><%=(Recordset1.Fields.Item("vote_title").Value)%></td>
    </tr>
    <%
'JomoWeb c2001 nstrpt3
if "Recordset2" <> "Recordset1" then
  Recordset2.close()
  if Recordset1.state = 1 then Recordset1_Fld = Recordset1("vote_id")
Recordset2.source = Recordset2_prefix & Recordset1_Fld & Recordset2_postfix
  Recordset2.open()
end if
while NOT Recordset2.EOF
 %><tr>
      <td><%=(Recordset2.Fields.Item("vote_content").Value)%></td>
    </tr>
    <%
'JomoWeb c2001 nstrpt4
Recordset2.moveNext()
wend
 %>
  </table>
  <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>


我初学做网站,请各位多多指点,谢谢!

回复列表 (共1个回复)

沙发

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 该特定字段 'vote_id' 可以参考 SQL 语句中 FROM 子句列表中的多个表。
/yidais/VoteSystem/huizong.asp, 第 97 行

此错误类型一般见于多表连查的情况下。
也就是说你的SQL语句写错了。

举个例子 有张学生表 有张成绩表 
学生表字段  student
id 学生编号
s_num 学生学号
s_name 学生姓名

成绩表  chengji
id 主键,自动编号
c_num 学生学号
c_chengji 成绩

要求查询学生的编号 学号 姓名 成绩 那么 错误的SQL语句如下
select id,s_num,s_name,c_chengji from student,chengji where s_num=c_num

那么如上就会产生你那样的错误 为什么 以为其中id字段的标志不明确,计算机不能识别这个id是属于表student 还是表chengji 正确的写法 你必须在重名的id字段前加入表的限定符,如下。

select student.id,s_num,s_name,c_chengji from student,chengji where s_num=c_num
当然 你在多表联查中也可以为任何字段加上表的限定符

我来回复

您尚未登录,请登录后再回复。点此登录或注册