listview显示问题
以下是在ListView1中显示表的程序Private Sub TreeView1_nodeclick(ByVal node As MSComctlLib.node)
Dim conn2 As ADODB.Connection
Dim rst2 As ADODB.Recordset
Dim item As ListItem
Dim ftype As Integer
If node.Image = 3 Then
Text1 = Trim(node.Text) + "表记录"
ListView1.ColumnHeaders.Clear
ListView1.ListItems.Clear
Set conn2 = New ADODB.Connection
Set rst2 = New ADODB.Recordset
conn2.ConnectionString = "provider=sqloledb;driver=(sql server);" + _
"server=WWW-D4CC14DD61C;uid=sa;pwd=xywnhy2005;database=" & _
Trim(node.Parent.Text)
conn2.CursorLocation = adUseServer
conn2.Open
rst2.LockType = adLockPessimistic
rst2.CursorType = adOpenDynamic
rst2.ActiveConnection = conn2
rst2.Open "select * from " & Trim(node.Text)
For i = 0 To rst2.Fields.Count - 1
ListView1.ColumnHeaders.Add , , rst2.Fields(i).Name
Next i
ListView1.View = lvwReport
If Not rst2.BOF And Not rst2.EOF Then
Do While Not rst2.EOF
If Not IsNull(rst2.Fields(0)) Then
Set item = ListView1.ListItems.Add(, , rst2.Fields(0))
For i = 0 To rst2.Fields.Count - 1
If Not IsNull(rst2.Fields(i)) Then
ftype = rst2.Fields(i).Type
If ftype <> adbyref And ftype <> adLongVarBinary And _
ftype <> adLongVarChar And ftype <> adLongVarWChar And _
ftype <> adIDispatch Then
item.SubItems(i) = rst2.Fields(i) (这里运行后说无效数据, item.subitems(i)=无效数据 rst2.fields(i)="1 ")
End If
End If
Next i
End If
rst2.MoveNext
Loop
End If
End If
Set rst2 = Nothing
Set conn2 = Nothing
End Sub
怎么调试~~~~~~~~~~~~~~~~~~
请大家多多帮忙~
先谢过了~~~~