| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 559 人关注过本帖
标题:listview显示问题
只看楼主 加入收藏
xywnhy
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2010-4-8
结帖率:33.33%
收藏
已结贴  问题点数:10 回复次数:2 
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



怎么调试~~~~~~~~~~~~~~~~~~
请大家多多帮忙~
先谢过了~~~~
搜索更多相关主题的帖子: listview 
2010-04-13 11:34
czyzhuo
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:17
帖 子:230
专家分:1459
注 册:2010-3-11
收藏
得分:5 
超出列数范围了
2010-04-15 09:18
happynight
Rank: 8Rank: 8
等 级:贵宾
威 望:15
帖 子:807
专家分:760
注 册:2008-4-26
收藏
得分:5 
"provider=sqloledb;driver=(sql server);" + _
      "server=WWW-D4CC14DD61C;uid=sa;pwd=xywnhy2005;database="
注意安全啊 另你的问题最好发到VB版块
2010-04-15 10:32
快速回复:listview显示问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016002 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved