無法MovePrevious

1<html>
2<head>
3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
4</head>   
5  

<!--#include virtual="adovbs.inc"-->
Server.ScriptTimeOut = 6000

'Define all varity
Dim wagebhConn
Dim iepa00hRs
Dim found
Dim last_pa_no,current_pa_no,next_pa_no
found=0
start_time=now()
Set wagebhConn=CreateObject("ADODB.Connection")
wagebhConn.Open "FILEDSN=C:\Program Files\Common Files\ODBC\Data Sources\wagebh.dsn"
Set iepa00hRs=CreateObject("ADODB.Recordset")
sql="SELECT pa_no,pa_name,pa_indat,dp_no,pa_tino,pa_ssno FROM iepa00h"
'Set iepa00hRs=wagebhConn.Execute(sql,1,1)
iepa00hRs.open sql,wagebhConn,adopendynamic
WHILE NOT iepa00hRs.EOF
if (iepa00hRs.BOF) then
last_rd=0
current_rd=cint(iepa00hRs("pa_no"))
iepa00hRs.MoveNext
last_rd=cint(iepa00hRs("pa_no"))
else
iepa00hRs.MoveNext
iepa00hRs.MoveFirst
iepa00hRs.MovePrevious
last_rd=cint(iepa00hRs("pa_no"))
iepa00hRs.MoveNext
current_rd=cint(iepa00hRs("pa_no"))
iepa00hRs.MoveNext
next_rd=cint(iepa00hRs("pa_no"))
if (current_rd+current_rd=last_rd+next_rd) then

iepa00hRs.MovePrevious
found=found+1
end if
END IF
iepa00hRs.MoveNext

WEND
iepa00hRs.Close
wagebhConn.Close

1</html>

這是我的代碼﹐掃行到iepa00hRs.MovePrevious就不行了﹐但是MoveNext方法沒問題。執行的結果的如下﹕
HTTP 500.100 - 內部伺服器錯誤 - ASP 錯誤
Internet Information Services

--------------------------------------------------------------------------------

技術資訊 (供技術支援人員使用)

錯誤類型:
ADODB.Recordset (0x800A0C93)
在這個範圍中不允許操作。
/hr/find.asp, line 63

瀏覽器類型:
Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)

頁數:
GET /hr/find.asp

時間:
2002年12月16日, 下午 03:57:55

---------------------------------------------------------------

要进行bof判断,否则记录集越界.
---------------------------------------------------------------

try:iepa00hRs.open sql,1,3
---------------------------------------------------------------

iepa00hRs.open sql,3,3

Published At
Categories with Web编程
Tagged with
comments powered by Disqus