我用DATAGRID连ACCESS数据库,用RECORDSET作为DATAGRID的数据源,现在我想CLICK事件里得到DATAGRID中相应的数据,可是,在第一次响应CLICK事件时,返回的Row值却是-1,当第2次CLICK才能正常得到我要的数据,怎么回事???该怎么解决?????代码如下:
RSRefrence.CursorLocation = adUseClient 'important
SQLString2 = "SELECT DISTINCT 维护号码,用户名称 FROM extrefrence"
RSRefrence.Open SQLString2, CnRefrence, adOpenDynamic, adLockOptimistic
Set DGBill.DataSource = RSRefrence
If DGBill.Row >= 0 Then
WHText(1) = DGBill.Columns(1).Text
End If
各位好心人,帮帮忙!!

解决方案 »

  1.   

    RSRefrence.CursorLocation = adUseClient 'important
    SQLString2 = "SELECT DISTINCT 维护号码,用户名称 FROM extrefrence"
    RSRefrence.Open SQLString2, CnRefrence, AdOpenKeyset, adLockOptimistic
    Set DGBill.DataSource = RSRefrence
    If DGBill.Row >= 0 Then
    WHText(1) = DGBill.Columns(1).Text
    End If
      

  2.   

    放在RowColChange事件中试一试!
      

  3.   

    Hello:
       seaiam please go back home and ask your mother who is your father