即怎么判断是
Recordset.open
还是
Recordset.close

解决方案 »

  1.   

    Recordset.StateAdStateClosed 默认,指示对象是关闭的。 
    AdStateOpen 指示对象是打开的。 
    AdStateConnecting 指示 Recordset 对象正在连接。 
    AdStateExecuting 指示 Recordset 对象正在执行命令。 
    AdStateFetching 指示 Recordset 对象的行正在被读取。 
    说明可以随时使用 State 属性确定指定对象的当前状态。该属性是只读的。Recordset 对象的 State 属性可以是组合值。例如,如果正在执行语句,该属性将是 adStateOpen 和 adStateExecuting 的组合值。
      

  2.   

    Dim mRst As New ADODB.Recordset
    If mRst.State = adStateOpen Then
            mRst.Close
    End If
      

  3.   

    Recordset.State=1就是打开,0就是关闭
      

  4.   

    If rs.State = adStateOpen then rs.Close
    rs.Open strSQL, cn
      

  5.   


    这里有几个VB中的常数,可以参考一下:
    adStateClosed = 0
    adStateOpen = 1
    adStateConnecting = 2
    adStateFetching = 8
    adStateExecuting = 4比如
    If rs.State = adStateOpen then 
       ---
    else
       ---
    end if