vb运行出现3021错误,EOF或BOF为真的情况,麻烦高手帮解决一下 10

'临时课表DimctConAsADODB.ConnectionDimctrsAsADODB.Recordset'classArray表DimcaconAsADODB.Co... '临时课表
Dim ctCon As ADODB.Connection
Dim ctrs As ADODB.Recordset
'classArray表
Dim cacon As ADODB.Connection
Dim cars As ADODB.Recordset
Dim sqlStr As String
Dim ClassCode As String
Dim wStr(5) As String

Private Sub clearStr()
For i = 1 To 5
wStr(i) = " "
Next i
End Sub

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 If

End Sub

Private Sub Command1_Click()
ClassCode = Trim(gradeCombox.Text) & "." & Trim(classCombox.Text)
Call Update_ct
Unload Me
classRep.Show
End Sub

Private Sub Form_Load()
For i = 1 To 12
gradeCombox.AddItem (i)
Next i
For i = 1 To 20
classCombox.AddItem (i)
Next i

Set cacon = New ADODB.Connection
Set cars = New ADODB.Recordset

cacon.Open "provider=Microsoft.Jet.OLEDB.4.0; data source= " & App.Path & "\dataUse.mdb"

Set ctCon = New ADODB.Connection
Set ctrs = New ADODB.Recordset

ctCon.Open "provider=Microsoft.Jet.OLEDB.4.0; data source= " & App.Path & "\dataUse.mdb"
End Sub

Private Sub Form_Unload(Cancel As Integer)
cars.Close
cacon.Close
Set cars = Nothing
Set cacon = Nothing
ctCon.Close
Set ctrs = Nothing
Set ctCon = Nothing
End Sub
cars.MoveFirst处报错
展开
 我来答
xianing775
2012-06-05 · TA获得超过127个赞
知道小有建树答主
回答量:604
采纳率:0%
帮助的人:200万
展开全部
代码出错?查看那个语法不对呀
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式