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处报错 展开
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处报错 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询