ADODB.Recordset (0x800A0E78)对象关闭时,不允许操作

来源:百度知道 编辑:UC知道 时间:2024/05/31 17:23:38
<%@language=vbscript codepage=936 %>
<!--#include file="../houtai2/articleconn.asp"-->
<script language="javascript">
function checkform()
{
if(confirm("你确定按当前条件查询么?"))
{
return true;
}
else
{
return false;
}
}
</script>
<%
position=request.Form("position")
i_date=request.Form("date")

dim f_position,f_number,f_locus,f_description,f_demand,f_recordcount,f_absolutepage

set rs=server.CreateObject("adodb.recordset")

if position="" and i_date<>"" then
sql="select * from invite where i_date like '"&i_date&"%'"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
f_position=""
f_number=""
f_locus=""
f_description=""
f_demand=""

二个比较大的问题:

一.
if request.QueryString("test")=0 then
rs.MovePrevious '此地出错
if not rs.bof then

因为 recordset 运行完就在 bof 了,你要先做 recordset 是否在 bof 的判决断,才能决定是否 recordset.MovePrevious.

二.
recordset 中有需要用到 MovePrevious, Movenext , 就要用廻圈, 例如 while , 否则程序由上到下只跑一次, 根本没有办法 MovePrevious, Movenext ...

下面是廻圈和自定函数的范例:不过跑起来是没什么意义的。

if position="" and i_date<>"" then
sql="select * from invite where i_date like '"&i_date&"%'"
rs.open sql,conn,1,1
while not rs.eof <<---- 廻圈起点(意思是:当 不是 rs.尾端 ,运行廻圈中间这段程序)
SetValue(1) <--使用自定函数
rs.movenext
end while <<---- 廻圈终点
SetValue(2)
end if

sub SetValue(tmpS) <--自定函数
if tmpS=1 then
f_position=rs("i_position")
f_number=rs("i_number")
f_locus=rs("i_locus")
f_descript