VB 中实时错误'3021',BOF或EOF中有一个是"真",或者当前的记录以被删除,所需的操作要求一个当前的记录

PrivateSubUpdate_ct()'删除所有以前的记录CtCon.Execute("delete*fromtempCT")'更新表sqlStr="select*f... Private Sub Update_ct()
'删除所有以前的记录
CtCon.Execute ("delete * from tempCT")
'更新表
sqlStr = "select * from classArray where cClassCode='" & ClassCode & "'" & " order by iTimeN"
cacon.Execute sqlStr
cars.Open sqlStr, cacon, adOpenStatic, adLockOptimistic
cars.MoveFirst
Dim i As Integer
i = 1
clearStr
While (Not cars.EOF)
While cars!iTimeN <> i
'添加一条课程记录
strSql = "insert into tempCT values(" & i & " ," + "'" + wStr(1) + "' ," + "'" + wStr(2) + "' ," + "'" + wStr(3) + "' ," + "'" + wStr(4) + "' ," + "'" + wStr(5) + "' )"
CtCon.Execute strSql
clearStr
i = i + 1
Wend
wStr(cars!iTimeW) = cars!csjname
cars.MoveNext
Wend
'添加一条课程记录
strSql = "insert into tempCT values(" & i & " ," + "'" + wStr(1) + "' ," + "'" + wStr(2) + "' ," + "'" + wStr(3) + "' ," + "'" + wStr(4) + "' ," + "'" + wStr(5) + "' )"
CtCon.Execute strSql
clearStr
While i < 10
'添加一条课程记录
strSql = "insert into tempCT values(" & i & " ," + "'" + wStr(1) + "' ," + "'" + wStr(2) + "' ," + "'" + wStr(3) + "' ," + "'" + wStr(4) + "' ," + "'" + wStr(5) + "' )"
CtCon.Execute strSql
i = i + 1
Wend
End Sub

错误出在cars.MoveFirst
展开
 我来答
影墨者
2010-01-21 · TA获得超过297个赞
知道小有建树答主
回答量:307
采纳率:0%
帮助的人:190万
展开全部
在这句话之前加一个判断
if not cars.bof and not cars.eof then
cars.movefirst
end if
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式