求指导:vb 运行时报run-time errors '3704'的错误怎么解决
本帖最后由 zwx1991 于 2012-06-26 12:22:35 编辑 代码如下:求大侠指导
把Do While Not RsUser.EOF去掉之后运行正常。一旦加上就报run-time errors '3704'(“对象关闭时,不允许操作”)这个错误。
Private Sub Form_Load()
Dim StrSql As String
Dim RsUser As New ADODB.Recordset
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "用户名"
ListView1.ColumnHeaders.Add , , "说明"
ListView1.ColumnHeaders.Add , , "状态"
Dim itmX As MSComCtllib.ListItem
'Dim i As Integer
StrSql = "SELECT UserName,UserPosition,UserState FROM t_User"
If link.ResultExecRs(RsUser, StrSql) = True Then
ListView1.ListItems.Clear
Do While Not RsUser.EOF
Set itmX = ListView1.ListItems.Add(, , RsUser!UserName)
itmX.SubItems(1) = RsUser!UserPosition
itmX.SubItems(2) = RsUser!UserState
RsUser.NextRecordset
Loop
Else
End If
End Sub