Private Sub Init()
Dim SQL As String
Dim strMyFilter As StringIf (RoadType = 0) Then
    SQL = "Select BeginMileShow,CX,GQ,YZPSB,KD,BJPL,LG,PZDC,CT,JN,YZLF,ZDLF,QWLF,JFYHC,ZH,BeginMile From " & RoadTableLocalNow & "  Order By BeginMile ASC"
Else
    SQL = "Select BeginMileShow,KC,FJ,CX,YB,SS,GL,CZ,TP,KB,FY,WL,BL,PZDC,HPBS,ZH,BeginMile from " & RoadTableLocalNow & " Order By BeginMile ASC"
End IfrsLocalNow.Open SQL, con, adOpenDynamic, adLockOptimistic
rsLocalNow.MoveFirst
SQL = "Select * from " & RoadPicTable & ""
rsPicNow.Open SQL, con, adOpenDynamic, adLockOptimisticIf (RoadType = 0) Then
    Set DataGrid1.DataSource = rsLocalNow
    DataGrid1.Columns(0).Caption = "起始公里数"
    DataGrid1.Columns(1).Caption = "沉陷"
    DataGrid1.Columns(2).Caption = "拱起"
    DataGrid1.Columns(3).Caption = "严重破碎板"
    DataGrid1.Columns(4).Caption = "坑洞"
    DataGrid1.Columns(5).Caption = "板角破裂"
    DataGrid1.Columns(6).Caption = "露骨"
    DataGrid1.Columns(7).Caption = "平整度差"
    DataGrid1.Columns(8).Caption = "错台"
    DataGrid1.Columns(9).Caption = "唧泥"
    DataGrid1.Columns(10).Caption = "严重裂缝"
    DataGrid1.Columns(11).Caption = "中等裂缝"
    DataGrid1.Columns(12).Caption = "轻微裂缝"
    DataGrid1.Columns(13).Caption = "接缝养护差"
    DataGrid1.Columns(14).Caption = "帧号"
    DataGrid1.Refresh
Else
    Set DataGrid1.DataSource = rsLocalNow
    DataGrid1.Columns(0).Caption = "起始公里数"
    DataGrid1.Columns(1).Caption = "坑槽"
    DataGrid1.Columns(2).Caption = "翻浆"
    DataGrid1.Columns(3).Caption = "沉陷"
    DataGrid1.Columns(4).Caption = "拥包"
    DataGrid1.Columns(5).Caption = "松散"
    DataGrid1.Columns(6).Caption = "龟裂"
    DataGrid1.Columns(7).Caption = "车辙"
    DataGrid1.Columns(8).Caption = "脱皮"
    DataGrid1.Columns(9).Caption = "啃边"
    DataGrid1.Columns(10).Caption = "泛油"
    DataGrid1.Columns(11).Caption = "网裂"
    DataGrid1.Columns(12).Caption = "波浪"
    DataGrid1.Columns(13).Caption = "平整度差"
    DataGrid1.Columns(14).Caption = "横坡不适"
    DataGrid1.Columns(15).Caption = "帧号"
    DataGrid1.Refresh
End If
End SubPrivate Sub Form_Activate()
if Me.ScaleWidth>100 then
   DataGrid1.Width = Me.ScaleWidth - 100
end if
if  Me.ScaleHeight > 500 then
    DataGrid1.Height = Me.ScaleHeight - 500
end if
End SubPrivate Sub Form_Load()
   Init
End SubPrivate Sub Form_Unload(Cancel As Integer)
   rsLocalNow.Close
   rsPicNow.Close
   Unload Me
End Sub点击一个按钮进入该窗体,然后退出,什么操作都不作,只要重复两次,就会弹出对话框,显示“the current row is not available”

解决方案 »

  1.   

    随便看了一下,应该是数据库中没有记录,但又操作了指针
    rsLocalNow.MoveFirst
    可能是上面这个语句吧你再看看吧
      

  2.   

    ivt:
    谢了
    不加那句也不行啊
    wo shi guo le
      

  3.   

    首先判断一个记录集中有无记录然后作赋值处理!
    if rs.recordcount>0 then
       rs.movefirst
       do until rs.eof
       ....
       loop
    end if
      

  4.   

    是没有数据, Movefirst 会 ErrorOpen 之后,不必Movefirst可能是 ADO Version 问题,或未安装 VB Pack 5 。数据最好有 Key/ID 才好。