| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 668 人关注过本帖
标题:[求助]急于求助一个ASP报错问题
取消只看楼主 加入收藏
zln
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2006-1-6
收藏
 问题点数:0 回复次数:3 
[求助]急于求助一个ASP报错问题

请各位高手帮忙看看,以下是我的一个文件搜索页面,是按关键字和日期同时满足两都条件进行的搜索
程序存在有两个问题:
1.错误类型:
ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/hqjtims/searchdoc.asp, 第 29 行rs.open,conn,1,1为出错语句
2.程序中有**年至**年的搜索功能
我用range1和range2分别接收提交的内容,但不知道怎么实现用一个变量来接收上述二者的内容
代码如下:
<!--#include file = "conn.asp" -->
<%
if session("admin") = "" then
response.redirect "logincha.asp"
response.end
end if

Dim sKeyWord,sRange,range1,range2,keyword,page
sKeyWord = trim(request.form("keyword"))
range1 = GetSafeStr(Trim(Request("range1")))

range2 = GetSafeStr(Trim(Request("range2")))

if sKeyWord<>"" then
sKeyWord = ReplaceBadChar(sKeyWord) '过滤非法的SQL字符
else
sKeyWord = trim(request.querystring("keyword"))
end if
if( range1 = "" ) then
range1 = trim(request.querystring("range1"))
end if
if( range2 = "" ) then
range2= trim(request.querystring("range2"))
end if


dim sql,nPage,i,nCurCount,ID
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,3,3
sql = "select ID,FileName,Btime from News where FileName like '%"&sKeyWord&"%' and Btime between #"&range1&"# and #"&range2&"# Order By ID desc"


nPage = request.form("page")
if( nPage = "" ) then
nPage = request.querystring("page")
if( nPage = "" ) then
nPage = "1"
end if
end if
if( IsNumeric(nPage) = false )then '页码非数字类型时
nPage = 1
end if
nPage = Clng(nPage)
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" type="text/css" href="Css.css">
<title>文件信息搜索</title>

<Script Language="Javascript">
function unSelectAll()
{
if(document.myform.chkAll.checked){ //选中所有状态已经选择时,再取消一个单元的选择时
document.myform.chkAll.checked = document.myform.chkAll.checked&0; //原状态取反
}
}

function CheckAll()
{
for (var i=0;i<document.myform.elements.length;i++)
{
var e = document.myform.elements;
if (e.Name != "chkAll"&&e.disabled==false) //非chkAll单元且可操作的单元状态设置
e.checked = document.myform.chkAll.checked;
}
}

function ConfirmDel()
{
var flag = false;
for(var i=0; i < document.myform.elements.length; i++)
{
if(document.myform.elements.checked){
flag = true;
break;
}
}
if( flag == false )
return false;
if(confirm("确定要彻底删除选中的信息吗?一旦删除将不能恢复!"))
return true;
else
return false;
}

</Script>

</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><b>文件搜索</b></div></td>
</tr>
<tr>
<td><hr size="1"></td>
</tr>
</table>
<form name="SearchForm" method="post" action="search.asp?action=search"> <!--信息搜索表单-->
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#999999">
<tr>
<td bgcolor="#F5C84E"> 1、请输入关键字:
<input type="text" name="keyword">  
 2、请选择检索时间:
<select name="range1" size="1" id="select2">
<option value="2005-01-01">2005-01-01</option>
<option value="2005-07-01">2005-07-01</option>
<option value="2006-01-01">2006-01-01</option>
<option value="2006-07-01">2006-07-01</option>
<option value="2007-01-01">2007-01-01</option>
<option value="2007-07-01">2007-07-01</option>
<option value="2008-01-01">2008-01-01</option>
<option value="2008-07-01">2008-07-01</option>
<option value="2009-01-01">2009-01-01</option>
<option value="2009-07-01">2009-07-01</option>
</select>
至 
<select name="range2" size="1" id="range2">
<option value="2005-06-30">2005-06-30</option>
<option value="2005-12-31">2005-12-31</option>
<option value="2006-06-30">2006-06-30</option>
<option value="2006-12-31">2006-12-31</option>
<option value="2007-06-30">2007-06-30</option>
<option value="2007-12-31">2007-12-31</option>
<option value="2008-06-30">2008-06-30</option>
<option value="2008-12-31">2008-12-31</option>
<option value="2009-06-30">2009-06-30</option>
<option value="2009-12-31">2009-12-31</option>
</select> 
3、请点击
<input name="search" type="submit" id="search" value="搜索"></td>
</tr>
</table>
</form>

<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>  你输入的关键字为:<font color="#ff0000"><strong><%=sKeyWord%></strong></font>,所选择的检索范围为:<font color="#ff0000"><strong><%=range1%></strong></font>,搜索结果如下表所示:</td>
</tr>
</table>
<%
if( rs.eof ) then
response.write "<H1><div align='center'>没有找到任何合适的信息!</div></H1>"
else
%>
<!-- 表单开始 -->
<form name="myform" method="Post" action="deletedoc.asp?page=<%=nPage%>&action=select" onsubmit="return ConfirmDel();">
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#999999">
<tr bgcolor="#E1E1E1">
<td width="6%"><div align="center">状态</div></td>
<td width="46%"><div align="center">文件名</div></td>

<td width="12%"><div align="center">加入时间</div></td>

<td width="8%"><div align="center">修改</div></td>
<td width="8%"><div align="center">删除</div></td>
</tr>
<%
rs.pagesize = 20
if( nPage<1 or nPage>rs.pagecount ) then
nPage = 1
end if
rs.absolutepage = nPage
if( (nPage = rs.pagecount) and (rs.recordcount mod rs.pagesize <> 0) ) then
nCurCount = rs.recordcount mod rs.pagesize '计算当前页中含有的记录条数
else
nCurCount = rs.pagesize '当当前页不为最后一页时,都将含有pagesize条
end if
for i=1 to nCurCount
%>
<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#F7F8F8'">
<td><div align="center">
<input name="sNewsID" type="checkbox" id="sNewsID" value="<%=rs("ID")%>" onClick="unSelectAll()">
</div></td>
<td><a href="show.asp?id=<%=rs("ID")%>&page=<%=nPage%>"><%=rs("FileName")%></a></td>

<td><div align="center"><%=rs("Btime")%></div></td>

<td><div align="center"><a href="edit.asp?id=<%=rs("ID")%>&page=<%=nPage%>">修改</a></div></td>
<td><div align="center"><a href="deletedoc.asp?id=<%=rs("ID")%>&page=<%=nPage%>&action=one">删除</a></div></td>
</tr>
<%
rs.movenext
next
%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
</tr>
<tr>
<td><div align="center"><%
response.write "总共<font color='#ff0000'>"&rs.recordcount&"</font>篇,"
response.write "目前是<font color='#ff0000'>"&nPage&"/"&rs.pagecount&"</font>页"
response.write " "

if( nPage = 1 ) then
response.write "【首页】"
response.write "【上一页】"
else
response.write "<a href='searchdoc.asp?page=1&keyword="&sKeyWord&"&range="&sRange&"'>【首页】</a>"
response.write "<a href='searchdoc.asp?page="&nPage-1&"&keyword="&sKeyWord&"&range="&sRange&"'>【上一页】</a>"
end if

if( nPage = rs.pagecount ) then
response.write "【下一页】"
response.write "【尾页】"
else
response.write "<a href='searchdoc.asp?page="&nPage+1&"&keyword="&sKeyWord&"&range="&sRange&"'>【下一页】</a>"
response.write "<a href='searchdoc.asp?page="&rs.pagecount&"&keyword="&sKeyWord&"&range="&sRange&"'>【尾页】</a>"
end if
%></div></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><hr></td>
</tr>
<tr>
<td> 
<input name="chkAll" type="checkbox" id="chkAll" value="checkbox" onClick="CheckAll()"><!--表单元的名不能与函数同名-->
全选/取消全选
<input type="submit" name="Submit" value=" 删除所选 "></td>
</tr>
</table>
</form>
<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
<form action="searchdoc.asp?keyword=<%=sKeyWord%>&range=<%=sRange%>" method="post" name="formpage" id="formpage">
<tr>
<td bgcolor="#E1E1E1"> 转到:
<input name="page" type="text" class="input_text" id="page" size="6">

<input type="submit" name="Submit" value="提交"></td>
</tr>
</form>
</table>
<%end if%>
</body>
</html>
<%
rs.close
%>

搜索更多相关主题的帖子: ASP 搜索 变量 conn 
2007-06-18 11:54
zln
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2006-1-6
收藏
得分:0 

在这句话之前没有SQL语句了,还有就是请问一下&"&range="&sRange&"'这句话,
strange是由,range1和rang2的变量组合而成的。也就是相当于srange=range1=range2
rangge1是由2005-01-01,2006-01-01等组成的下拉框,同样range2也是由日期下拉框组成的.现在在某一处我想用srange变量显示出用户提交的某年某月某日-某年某月某日,请问这个strage变量应该怎样获取呢?谢谢!

2007-06-18 14:32
zln
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2006-1-6
收藏
得分:0 

刚才写错了哈,srange由range1和range2组成,
<select name="range1" size="1" id="select2">
<option value="2005-01-01">2005-01-01</option>
<option value="2005-07-01">2005-07-01</option>
<option value="2006-01-01">2006-01-01</option>
<option value="2006-07-01">2006-07-01</option>
<option value="2007-01-01">2007-01-01</option>
<option value="2007-07-01">2007-07-01</option>
<option value="2008-01-01">2008-01-01</option>
<option value="2008-07-01">2008-07-01</option>
<option value="2009-01-01">2009-01-01</option>
<option value="2009-07-01">2009-07-01</option>
</select>
至 
<select name="range2" size="1" id="range2">
<option value="2005-06-30">2005-06-30</option>
<option value="2005-12-31">2005-12-31</option>
<option value="2006-06-30">2006-06-30</option>
<option value="2006-12-31">2006-12-31</option>
<option value="2007-06-30">2007-06-30</option>
<option value="2007-12-31">2007-12-31</option>
<option value="2008-06-30">2008-06-30</option>
<option value="2008-12-31">2008-12-31</option>
<option value="2009-06-30">2009-06-30</option>
<option value="2009-12-31">2009-12-31</option>
</select> 
如果我想在程序某一处用srange来显示用户提交的range1-range2的年月日,请问srange该怎么写呢?

2007-06-18 14:44
zln
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2006-1-6
收藏
得分:0 

我换了一个分页代码,但程序还是报错:ADODB.Recordset (0x800A0BB9)
参数类型不正确,或不在可以接受的范围之内,或与其他参数冲突。
/hqjtims/searchdoc.asp, 第 50 行
出错语句为:rs.AbsolutePage = rs.PageCount (此时,数据表中已经有3条记录了)
源程序代码如下:
<!--#include file="conn.asp"-->
<!--#include file="showpage.asp"-->

<%if session("admin") = "" then
response.redirect "logincha.asp"
response.end
end if
%>

<%dim ID

page=trim(request.QueryString("page"))
nPage = trim(request.querystring("page"))


Dim sKeyWord,sRange,range1,range2,keyword,page,sql,nPage,i,nCurCount
sKeyWord = trim(request.form("keyword"))
range1 = GetSafeStr(Trim(Request("range1")))
range2 = GetSafeStr(Trim(Request("range2")))

if sKeyWord<>"" then
sKeyWord = ReplaceBadChar(sKeyWord) '过滤非法的SQL字符
else
sKeyWord = trim(request.querystring("keyword"))
end if
if( range1 = "" ) then
range1 = trim(request.querystring("range1"))
end if
if( range2 = "" ) then
range2= trim(request.querystring("range2"))
end if
Set rs = Server.CreateObject("ADODB.Recordset")
sql = "Select FileName,Btime from News where FileName like '%"&sKeyWord&"%' and Btime between '%"&range1&"%' and '%"&range2&"%'"
rs.open sql,conn,1,3

rs.pagesize = 20

if Not IsEmpty(page) then
if Not IsNumeric(page) then
page=1
Else
If page < 1 Then
page = 1
else
page = cint(page)
End if
end if

if page > rs.PageCount then
rs.AbsolutePage = rs.PageCount
elseif page <= 0 then
rs.AbsolutePage = 1
else
rs.AbsolutePage = page
end If
Else
page = 1
rs.AbsolutePage=1
end If

%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link rel="stylesheet" type="text/css" href="Css.css">
<title>文件信息搜索</title>

<Script Language="Javascript">
function unSelectAll()
{
if(document.myform.chkAll.checked){ //选中所有状态已经选择时,再取消一个单元的选择时
document.myform.chkAll.checked = document.myform.chkAll.checked&0; //原状态取反
}
}

function CheckAll()
{
for (var i=0;i<document.myform.elements.length;i++)
{
var e = document.myform.elements[i];
if (e.Name != "chkAll"&&e.disabled==false) //非chkAll单元且可操作的单元状态设置
e.checked = document.myform.chkAll.checked;
}
}

function ConfirmDel()
{
var flag = false;
for(var i=0; i < document.myform.elements.length; i++)
{
if(document.myform.elements[i].checked){
flag = true;
break;
}
}
if( flag == false )
return false;
if(confirm("确定要彻底删除选中的信息吗?一旦删除将不能恢复!"))
return true;
else
return false;
}

</Script>

</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><b>文件搜索</b></div></td>
</tr>
<tr>
<td><hr size="1"></td>
</tr>
</table>
<form name="SearchForm" method="post" action="search.asp?action=search"> <!--信息搜索表单-->
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#999999">
<tr>
<td bgcolor="#F5C84E"> 1、请输入关键字:
<input type="text" name="keyword">  
 2、请选择检索时间:
<select name="range1" size="1" id="select2">
<option value="2005-01-01">2005-01-01</option>
<option value="2005-07-01">2005-07-01</option>
<option value="2006-01-01">2006-01-01</option>
<option value="2006-07-01">2006-07-01</option>
<option value="2007-01-01">2007-01-01</option>
<option value="2007-07-01">2007-07-01</option>
<option value="2008-01-01">2008-01-01</option>
<option value="2008-07-01">2008-07-01</option>
<option value="2009-01-01">2009-01-01</option>
<option value="2009-07-01">2009-07-01</option>
</select>
至 
<select name="range2" size="1" id="range2">
<option value="2005-06-30">2005-06-30</option>
<option value="2005-12-31">2005-12-31</option>
<option value="2006-06-30">2006-06-30</option>
<option value="2006-12-31">2006-12-31</option>
<option value="2007-06-30">2007-06-30</option>
<option value="2007-12-31">2007-12-31</option>
<option value="2008-06-30">2008-06-30</option>
<option value="2008-12-31">2008-12-31</option>
<option value="2009-06-30">2009-06-30</option>
<option value="2009-12-31">2009-12-31</option>
</select> 
3、请点击
<input name="searchdoc" type="submit" id="searchdoc" value="搜索"></td>
</tr>
</table>
</form>

<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>  你输入的关键字为:<font color="#ff0000"><strong><%=sKeyWord%></strong></font>,所选择的检索范围为:<font color="#ff0000"><strong><%=range1%></strong></font>,搜索结果如下表所示:</td>
</tr>
</table>
<%
if( rs.eof ) then
response.write "<H1><div align='center'>没有找到任何合适的信息!</div></H1>"
else
%>

<form name="myform" method="Post" action="deletedoc.asp?page=<%=nPage%>&action=select" onsubmit="return ConfirmDel();">
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#999999">
<tr bgcolor="#E1E1E1">
<td width="6%"><div align="center">状态</div></td>
<td width="46%"><div align="center">文件名</div></td>

<td width="12%"><div align="center">加入时间</div></td>

<td width="8%"><div align="center">修改</div></td>
<td width="8%"><div align="center">删除</div></td>
</tr>

<%for i=1 to rs.PageSize%>

<tr bgcolor="#FFFFFF" onmouseout="this.style.backgroundColor=''" onmouseover="this.style.backgroundColor='#F7F8F8'">
<td><div align="center">
<input name="sNewsID" type="checkbox" id="sNewsID" value="<%=rs("ID")%>" onClick="unSelectAll()">
</div></td>
<td><a href="show.asp?id=<%=rs("ID")%>&page=<%=nPage%>"><%=rs("FileName")%></a></td>

<td><div align="center"><%=rs("Btime")%></div></td>

<td><div align="center"><a href="edit.asp?id=<%=rs("ID")%>&page=<%=nPage%>">修改</a></div></td>
<td><div align="center"><a href="deletedoc.asp?id=<%=rs("ID")%>&page=<%=nPage%>&action=one">删除</a></div></td>
</tr>
<%
rs.MoveNext()
if rs.eof or rs.bof then exit for
next
%>
</table>
<table width="100%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
<tr><td>
[<a href="searchdoc.asp?ID=<%=ID%>&page=<% = 1%>">首页</a>]
<% if page >= 1 then%>
[<a href="searchdoc.asp?ID=<%=ID%>&page=<% = page -1 %>">上一页</a>]
<%if page < rs.pagecount then %>
[<a href="searchdoc.asp?ID=<%=ID%>&page=<% = page + 1%>">下一页</a>]
<%else%>
[下一页]
<%end if%>
<%else%>
[上一页]
[下一页]
<%end if %>
[<a href="searchdoc.asp?ID=<%=ID%>&page=<% = rs.PageCount%>">尾页</a>]
[页次:<font color=red><b><%=page%></b></font>/<%=rs.PageCount%>]
[每页<b> <%=rs.PageSize%> </b></font>条/共 <%=rs.RecordCount%> 条]
</td>
</tr>


<tr>
<td><hr></td>
</tr>
<tr>
<td> 
<input name="chkAll" type="checkbox" id="chkAll" value="checkbox" onClick="CheckAll()"><!--表单元的名不能与函数同名-->
全选/取消全选 &nbsp;&nbsp;&nbsp;
<input type="submit" name="Submit" value=" 删除所选 "></td>
</tr>
</table>
</div>
</form>



<p align="center"><a href="file.asp">返回</a></p>


</tr>
</table>

</body>
</html>
<%
end if
rs.close
set rs = nothing
conn.close
set conn = nothing
%>

2007-06-18 16:17
快速回复:[求助]急于求助一个ASP报错问题
数据加载中...
 
   



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

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