标题:带原代码请教 vb+access问题?
只看楼主
knight1212
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2007-8-28
 问题点数:0 回复次数:3 
带原代码请教 vb+access问题?
Private Sub line(ByRef X1 As Long, ByRef X2 As Long, ByRef Y1 As Long, ByRef Y2 As Long, ByRef id As Integer)

 Dim strsql As String
   Dim i As Integer
   Dim j As Integer
   Dim count As Integer
   Dim rsrecord As Recordset
   Dim ii As Integer
   On Error Resume Next
   Set dbdao = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\lddatabase.mdb") '打开数据库
   strsql = "select * from line" & " order by address"
   Set rsrecord = dbdao.OpenRecordset(strsql)
   
   If rsrecord.RecordCount > 0 Then
        
       For i = 1 To TreeView1.Nodes.count - 2
          rsrecord.MoveFirst
         For j = 1 To rsrecord.RecordCount
        
         
          If TreeView1.Nodes(TreeIndex).Index = rsrecord.Fields("address") Then
'
            X1 = rsrecord.Fields("x1")
            X2 = rsrecord.Fields("x2")
            Y1 = rsrecord.Fields("y1")
            Y2 = rsrecord.Fields("y2")
            '//////////////////////////////////////////////////
            Lin(j - 1).X1 = X1
            Lin(j - 1).X2 = X2
            Lin(j - 1).Y1 = Y1
            Lin(j - 1).Y2 = Y2
            Lin(j - 1).Visible = True
            rsrecord.MoveNext
          Else
            
             Lin(j - 1).Visible = False
            
           rsrecord.MoveNext
          End If
         
          Next j
         
          If rsrecord.EOF Then rsrecord.MoveLast
          Set rsrecord = Nothing
       Next i
     
     
   End If
   

   On Error GoTo 0
请教,帮我看下数据库指针第一条和下移语句以及数据库判断是否正确.在运行时怎么感觉数据库记录没有下移.
先谢谢.在线等候!
搜索更多相关主题的帖子: access 代码 
2007-12-24 14:49
dawn4640576
Rank: 1
等 级:新手上路
帖 子:1079
专家分:0
注 册:2007-9-19
得分:0 
应该是语句位置的事.没仔细看, 你这样试试
   rsrecord.MoveFirst
For i = 1 To TreeView1.Nodes.count - 2
       For j = 1 To rsrecord.RecordCount

我看青山多妩媚料青山看我应如是
2007-12-24 15:18
knight1212
Rank: 1
等 级:新手上路
帖 子:76
专家分:0
注 册:2007-8-28
得分:0 
NO.也不行
2007-12-24 15:40
dawn4640576
Rank: 1
等 级:新手上路
帖 子:1079
专家分:0
注 册:2007-9-19
得分:0 
提示什么错误.
好像第一次循环的时候,你已经Set rsrecord = Nothing
你把  If rsrecord.EOF Then rsrecord.MoveLast
          Set rsrecord = Nothing
这两句去掉试一下.

我看青山多妩媚料青山看我应如是
2007-12-24 15:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-194053-1-1.html




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

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