求教查询系统的问题

dks2008 2008-04-18 08:35:11
刚接触动态网页,边学边做,在网站上做一个稿件查询系统,输入稿件编号和姓名就可查到稿件审核情况,数据库用access,用IE测试浏览显示:
错误类型:
Microsoft VBScript 编译器错误 (0x800A0401)
语句未结束
/mjwww/gjcx/cx2.asp, line 40, column 24
var Recordset1__MM = "%";
-----------------------^

我不知错在哪里,请各位指点一下,谢谢了。

源代码如下:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/link.asp" -->
<%
Dim Recordset2__MM
Recordset2__MM = "%"
If (Request.Form("a1") <> "") Then
Recordset2__MM = Request.Form("a1")
End If
%>
<%
Dim Recordset2__PP
Recordset2__PP = "%"
If (Request.Form("a2") <> "") Then
Recordset2__PP = Request.Form("a2")
End If
%>
<%
Dim Recordset2
Dim Recordset2_numRows

Set Recordset2 = Server.CreateObject("ADODB.Recordset")
Recordset2.ActiveConnection = MM_link_STRING
Recordset2.Source = "SELECT * FROM gjb WHERE 作者姓名 LIKE '" + Replace(Recordset2__MM, "'", "''") + "' AND 稿件编号 LIKE '" + Replace(Recordset2__PP, "'", "''") + "'"
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
Recordset2_numRows = Recordset2_numRows + Repeat1__numRows
%>
<%
var Recordset1__MM = "%";
if (String(Request.Form("a1")) != "undefined" &&
String(Request.Form("a1")) != "") {
Recordset1__MM = String(Request.Form("a1"));
}
%>
<%
var Recordset1__PP = "%";
if (String(Request.Form("a2")) != "undefined" &&
String(Request.Form("a2")) != "") {
Recordset1__PP = String(Request.Form("a2"));
}
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_link_STRING;
Recordset1.Source = "SELECT * FROM gjb WHERE 作者姓名 LIKE '"+ Recordset1__MM.replace(/'/g, "''") + "' AND 稿件编号 LIKE '"+ Recordset1__PP.replace(/'/g, "''") + "'";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
<%
var Repeat1__numRows = -1;
var Repeat1__index = 0;
Recordset1_numRows += Repeat1__numRows;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

// set the record count
var Recordset1_total = Recordset1.RecordCount;

// set the number of rows displayed on this page
if (Recordset1_numRows < 0) { // if repeat region set to all records
Recordset1_numRows = Recordset1_total;
} else if (Recordset1_numRows == 0) { // if no repeat regions
Recordset1_numRows = 1;
}

// set the first and last displayed record
var Recordset1_first = 1;
var Recordset1_last = Recordset1_first + Recordset1_numRows - 1;

// if we have the correct record count, check the other stats
if (Recordset1_total != -1) {
Recordset1_numRows = Math.min(Recordset1_numRows, Recordset1_total);
Recordset1_first = Math.min(Recordset1_first, Recordset1_total);
Recordset1_last = Math.min(Recordset1_last, Recordset1_total);
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them

if (Recordset1_total == -1) {

// count the total records by iterating through the recordset
for (Recordset1_total=0; !Recordset1.EOF; Recordset1.MoveNext()) {
Recordset1_total++;
}

// reset the cursor to the beginning
if (Recordset1.CursorType > 0) {
if (!Recordset1.BOF) Recordset1.MoveFirst();
} else {
Recordset1.Requery();
}

// set the number of rows displayed on this page
if (Recordset1_numRows < 0 || Recordset1_numRows > Recordset1_total) {
Recordset1_numRows = Recordset1_total;
}

// set the first and last displayed record
Recordset1_last = Math.min(Recordset1_first + Recordset1_numRows - 1, Recordset1_total);
Recordset1_first = Math.min(Recordset1_first, Recordset1_total);
}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查询结果</title>
</head>

<body>
<p>下面就是你要查询的稿件:
</p>
<table width="961" height="99" border="1">
<tr>
<th width="116" scope="col">稿件编号</th>
<th width="310" scope="col">稿件名称</th>
<th width="122" scope="col">作者姓名</th>
<th width="132" scope="col">初审</th>
<th width="118" scope="col">终审</th>
<th width="123" scope="col">备注</th>
</tr>
<% while ((Repeat1__numRows-- != 0) && (!Recordset1.EOF)) { %>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset2.EOF))
%>
<tr>
<td><%=(Recordset2.Fields.Item("稿件编号").Value)%></td>
<td><%=(Recordset2.Fields.Item("稿件名称").Value)%></td>
<td><%=(Recordset2.Fields.Item("作者姓名").Value)%></td>
<td><%=(Recordset2.Fields.Item("初审").Value)%></td>
<td><%=(Recordset2.Fields.Item("终审").Value)%></td>
<td><%=(Recordset2.Fields.Item("备注").Value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset2.MoveNext()
Wend
%>

<%
Repeat1__index++;
Recordset1.MoveNext();
}
%>
</table>
<p> </p>
</body>
</html>
<%
Recordset2.Close()
Set Recordset2 = Nothing
%>
<%
Recordset1.Close();
%>

...全文
55 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
dks2008 2008-04-21
  • 打赏
  • 举报
回复
感谢各位的帮助,问题已解决.
raoxu45 2008-04-18
  • 打赏
  • 举报
回复
把所有的javascript代码从asp代码中删除.
放入JAVAscript代码中.
raoxu45 2008-04-18
  • 打赏
  • 举报
回复
var Recordset1__MM = "%";

把这段代码放在javascript里
不能放在ASP里
因为这是Javascript语句.
a95470000 2008-04-18
  • 打赏
  • 举报
回复
如果你寫的是jscript
那你就不能把他們直接放在<%%>里﹐
<%%>里的代碼是在服務器端運行
而javascript是客戶端腳本語言

給你個范例看看﹐應該怎么寫

<!--#include file="../home/ekplogincheck.inc"-->
<!--#include file="../home/dbconnect.inc"-->
<!--#include file="../function/Genericfunction.inc"-->

<%
'---------------------全局變量區-------------------
vUId = Session("userid")
vGroupid = Session("groupid")
masterid = request.Cookies("DLC_ID")
strTime = getIntTime() '---刪除的節點的數據還保存在數據庫中﹐加上這個限制條件就不會查詢出來了
'--------------------------------------------------


'----------------------管理員權限判斷---------------------
if vGroupid = "" then
vGroupid = GetGroupIdByUser(vUId)
session("groupid") = vGroupid
end if

sSuppUser = false
ShowObj = PrjDesc
if instr(","& vGroupid &",",",1,") > 0 then
sSuppUser = true
end if
'---------------------------------------------------
%>
<html>
<head>
<title>Group Tree</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=big5"/>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<link href="./css/dtree.css" rel="StyleSheet" type="text/css" />
<script type="text/javascript" src="./JS/dtree.js"></script>
<script type="text/javascript" src="./JS/common.js"></script>
<style type="text/css">
<!-- '寫css時﹐先定位﹐再設置背景﹐邊框樣式﹐再設置文本﹐字體樣式' -->
.menuCss
{
padding-top: 4px;
margin-top: 1px;
height: 18pt;
background-color: #D6D3CE;
border: #FFFFFF 1px outset;
vertical-align: middle;
text-align: middle;
}

.fontCss
{
padding: 5px 70px 4px 70px;
height: 10px;
border: ridge 2px #ffffff;
font-size: 10px;
FILTER: Shadow(Color=#808080, Direction=225);

}
</style>
<script language="javascript">
var vEditId = '';
var vEditType = '';



function moveMenu(obj)
{
posX = document.body.scrollLeft + event.clientX + 9;
posY = document.body.scrollTop + event.clientY;
obj.style.left=posX;
obj.style.top=posY;
}

</script>
</head>
<body onclick="hideMenu(this)">
<B class="fontCss">THE TREE</B>
<form name='select'><input type='hidden' name='selectVal' id='selectVal' value=''></form>
<%
set oRs=server.createobject("adodb.recordset")
'-------------------------------This SQL list file tree------------------------------------------
if not sSuppUser then
'--------和樹狀結構瀏覽權限有關的
SQL = "SELECT master_id FROM data_auth " & _
" WHERE master_type = 1 AND view_type = 4 "&_
" AND ((auth_id = "& vUId &" AND auth_type = 2) or (auth_id IN ("& vGroupid &") AND auth_type =1)) " & _
" GROUP BY master_id"
'--------
sqlStr = "SELECT p.ID, p.parent_id, p.description "&_
"FROM project p, ("& SQL &") da "&_
"WHERE p.ID = da.master_id "&_
"AND p.effectfrom<='"& strTime &"' AND p.effectuntil>='"& strTime &"' "&_
"START WITH p.ID IN (124624) "&_
"CONNECT BY PRIOR p.ID = p.parent_id"
else
sqlStr = "SELECT p.ID, p.parent_id, p.description "&_
"FROM project p "&_
"WHERE p.effectfrom<='"& strTime &"' AND p.effectuntil>='"& strTime &"' "&_
"START WITH p.ID IN (124624) "&_
"CONNECT BY PRIOR p.ID = p.parent_id"
end if
oRs.cursorlocation=3
oRs.open sqlStr,conn,3,1
iMax = 0
if not oRs.eof then
iMax = oRs.recordCount
redim arrData(iMax,3)
end if
iRow = 0
ipIds = 0
while not oRs.eof
iRow = iRow + 1
arrData(iRow,1) = oRs.fields(0).value 'project id
arrData(iRow,2) = oRs.fields(1).value 'project parent_id
arrData(iRow,3) = oRs.fields(2).value 'project description
if iRow = 1 then
vTemp = arrData(iRow,1)
ipIds = vTemp
else
vTemp = ","& arrData(iRow,1)
ipIds = ipIds & vTemp
end if
oRs.movenext
wend
oRs.close
'------------------------------------------------------------------------------------------



'-----------------------------判斷user是否有對該節點下的文件清單維護權限---------------------------------
AuthSql = "SELECT master_id FROM data_auth "&_
" WHERE master_type = 1 AND master_id in ("& ipIds &") AND view_type = 5 AND auth_id = "& vUId &" AND auth_type = 2"&_
" UNION "&_
" SELECT master_id FROM data_auth "&_
" WHERE master_type = 1 AND master_id in ("& ipIds &") AND view_type = 5 AND auth_id IN ("& vGroupid &") AND auth_type = 1 "
oRs.open AuthSql,conn,3,1
strAuthId = ""
while not oRs.eof
vTemp = ","& oRs.fields(0).value 'project ID
strAuthId = strAuthId & vTemp
oRs.movenext
wend
vTemp = ","
strAuthId = strAuthId & vTemp
oRs.close
set oRs = nothing
conn.close
set conn = nothing
'----------------------------------------------------
%>
<form name="folderForm" action="" method="post">
<!-- 文件樹部分 -->
<div style="margin-left:10px;">
<script language="javascript" type="">
var dTree,dt;
dt = new dTree('dt');
dt.add(5,-1,"<%=Dict("Document Classification Tree")%>");
<%
for i=1 to iMax
iPid = arrData(i,1) 'project id
iPaId = arrData(i,2) 'project parent_id
idesc = arrData(i,3) 'project description
'---------對該節點操作的權限---------
mantainFlag =False
if sSuppUser then
mantainFlag =True
else
if strAuthId <>"" then
if instr(strAuthId, ","& iPid &",")>0 then mantainFlag =True
end if
end if
'-----------------------
strDescription=replace(replace(idesc,"""","""),"\","\\")
strURL = "eppData.asp?id=" & iPid
%>
dt.add(<%=iPid%>,<%=iPaId%>,"<%=strDescription%>","<%=strURL%>","<%=iPid%>","Data","<%=mantainFlag%>");
<%
next
%>
document.write(dt);
dt.openAll();
</script>
</div>
<!-- 點小圖標后出現的層 -->
<input type="hidden" name="hidProjId" />
<div id='func1' style='width:80;display:none;position:absolute;cursor:hand;'>
<div align='center' class='menuCss' onclick='menuFunc(1)'><%=dAdd%></div>
<div align='center' class='menuCss' onclick='menuFunc(2)'><%=dModify%></div>
<div align='center' class='menuCss' onclick='menuFunc(3)'><%=Dict("KM_Delete")%></div>
<div align='center' class='menuCss' onclick='menuFunc(4)' id='divCopy1'><%=Dict("EKP_COPY")%></div>
<div align='center' class='menuCss' onclick='menuFunc(5)' id='divCut1'><%=Dict("KM_Cut")%></div>
<div align='center' class='menuCss' onclick='menuFunc(6)' id='divPaste1' disabled ><%=dPaste%></div>
<div align='center' class='menuCss' onclick='menuFunc(7)' id='divCancelPaste1' disabled ><%=dUndoCut%></div>
</div>
</form>
</body>
</html>
a95470000 2008-04-18
  • 打赏
  • 举报
回复
vbscript 變量不是用var申明的
申明和初始化變量也不能同時進行


var Recordset1__MM = "%"; 要改成

dim recordset1_MM
recordset1_MM = "%"


不要"﹔"

4,008

社区成员

发帖
与我相关
我的任务
社区描述
它是一种微软环境下的轻量级的解释型语言,它使用COM组件、WMI、WSH、ADSI访问系统中的元素,对系统进行管理。
社区管理员
  • vbScript社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧