读书人

vb ado 有关问题

发布时间: 2012-01-20 18:53:53 作者: rapoo

vb ado 问题
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 50
Combo1.AddItem CStr(i)
Next
Combo1.ListIndex = 0
strpath = "Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source= " & App.Path & "\nce1.mdb; "

End Sub

Private Sub Label1_Click()
MsgBox "hello "

End Sub

Private Sub Label3_Click()
Dim i As Integer
i = Combo1.ListIndex + 1
MsgBox "已经选择了 "
bianshu = i
bofang

End Sub


Private Sub bofang()
Dim i As Integer
Dim cnn As New ADODB.Connection
cnn.ConnectionString = strpath

cnn.Open
Dim recordset As New ADODB.recordset
Set recordser = cnn.Execute( "select * from lesson1 ")
Dim field1 As ADODB.Field

Do While Not recordset.EOF
MsgBox CStr(recordset!开始时间)


Loop
cnn.Close
End Sub
-------------------------------------------------
以上为源代码,请问一下,怎么运行 总出现 对象关闭时,不允许操作?请帮帮忙!在线等,谢谢

[解决办法]
Set recordset = cnn.Execute( "select * from lesson1 ")

改成这个应该就没问题了
[解决办法]
你可以看看
Dim recordset As New ADODB.recordset
Set recordser = cnn.Execute( "select * from lesson1 ")

明显拼写错了

Do While Not recordset.EOF
MsgBox CStr(recordset!开始时间)

recordset.movenext ' 没有这个就造成死循环,很危险的
Loop

读书人网 >VB

热点推荐