| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1081 人关注过本帖
标题:报错求解
只看楼主 加入收藏
lg04405115
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2018-10-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
报错求解
   Public conn As New ADODB.Connection
   
   Public Rec As New ADODB.Recordset
   
    Dim stRecQL As String
   
    Dim Item As Integer
   
    Dim i, j, k As Integer
   
    Dim nodindex As Node

Private Sub Command1_Click()
Do Until Rec.EOF

 For j = 2 To Rec.Fields.Count - 1

  For i = 1 To Rec.RecordCount
  
       MSHFlexGrid1.TextMatrix(i, 1) = Rnd(1)

    Rec.MoveNext
    Next
    Next
Loop
End Sub

Private Sub Form_Load()

   
   
    With conn
        
        If .State = adStateClosed Then
           
           .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "/产量.mdb;Persist Security Info=False"
           
           .Open

        End If

    End With
   
   
    Set nodindex = TreeView.Nodes.Add(, , "爷", "井号", "K1")
   
    nodindex.Sorted = True
   
    '* -----------------------------------------------------------------
   
   
    Rec.Open "产量", conn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
  

    For i = 0 To Rec.RecordCount - 1

        Set nodindex = TreeView.Nodes.Add("爷", tvwChild, "父" & Rec.Fields("ID"), Rec.Fields("井号"), "K1")

        nodindex.Sorted = True

        Rec.MoveNext

    Next i


    'Rec.Close

    '* -----------------------------------------------------------------
   
   
End Sub


Private Sub TreeView_NodeClick(ByVal Node As MSComctlLib.Node)

Text1.Text = Rec.RecordCount



For k = 1 To TreeView.Nodes.Count

    For i = 2 To Rec.Fields.Count - 1

           MSHFlexGrid1.TextMatrix(0, i - 1) = Rec(i).Name

    Next i

    If TreeView.Nodes(k).Selected Then

        For j = 1 To Rec.RecordCount

            For i = 2 To Rec.Fields.Count - 1

                 MSHFlexGrid1.TextMatrix(j, i - 1) = Rec(i).Value

            Next i

          Rec.MoveNext

        Next j

    End If

Next k


End Sub
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: Sub For Fields Next End 
2018-10-24 16:08
lg04405115
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2018-10-24
收藏
得分:0 
Private Sub TreeView_NodeClick(ByVal Node As MSComctlLib.Node)

Text1.Text = Rec.RecordCount

Do While Not Rec.EOF

For k = 1 To TreeView.Nodes.Count

    For i = 2 To Rec.Fields.Count - 1

           MSHFlexGrid1.TextMatrix(0, i - 1) = Rec(i).Name

    Next i

    If TreeView.Nodes(k).Selected Then

        For j = 1 To Rec.RecordCount

            For i = 2 To Rec.Fields.Count - 1

                 MSHFlexGrid1.TextMatrix(j, i - 1) = Rec(i).Value

            Next i

        Rec.MoveNext

        Next j

    End If

Next k

Loop

添加了Do While Not Rec.EOF,为什么直接跳过了,不执行中间的语句,
图片附件: 游客没有浏览图片的权限,请 登录注册
2018-10-24 16:16
ZHRXJR
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:125
帖 子:1034
专家分:5519
注 册:2016-5-10
收藏
得分:20 
Rec.Open "产量", conn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
真搞不懂你的这个语句,不是打开记录集的标准语句,好好看看SQL语言中关于SQL打开记录集的连接代码吧!
Rec.Open "Select * From 产量", conn, adOpenKeyset, adLockOptimistic, adCmdTableDirect
参数 adOpenKeyset, adLockOptimistic, adCmdTableDirect 是游标打开类型的常量,不过我喜欢使用常量数字表示,例如:
Rec.Open "Select * From 产量", conn, 2, 2

请不要选我!!!
2018-10-25 10:17
快速回复:报错求解
数据加载中...
 
   



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

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