connection.state=0(连接)
connection.state=1(断开)

解决方案 »

  1.   

    connection.state=0(连接)
    connection.state=1(断开)
      

  2.   

    if connection.State=0 then
       '此连接是关闭的
    else
        '此连接是打开的
    endif
      

  3.   

    Sorry
    connection.state=1(连接)
    connection.state=0(断开)
      

  4.   

    我并不是问如何检查connection是否关闭。
    如果出现一般性网络错误的话,数据库的连接将断开,此时connection.state仍然是adStateOpen,即1。请问如何判断connection是否已经和数据库断开?
    谢谢!
      

  5.   

    Public Function isConnection(Optional ByVal sConnect As String) As Boolean
    Dim oConn       As Object
    Dim oRecordset  As Object
    Dim lErrNo      As Long
        
        On Error GoTo ErrorHandler
        
        Set oConn = New ADODB.Connection
        Set oRecordset = New ADODB.Recordset
         
        If Len(sConnect) Then
            oConn.Open sConnect
            oConn.Close
        End If    Set oRecordset = Nothing
        Set oConn = Nothing    isConnection = True
        Exit FunctionErrorHandler:
        
        lErrNo = Err.Number
        
        If lErrNo = [can't connectted] Then
           isConnection = False
        End If
        Set oRecordset = Nothing
        Set oConn = Nothing
        
    End Function
      

  6.   

    if connection.state = adStateOpen then
       '数据库的当前状态是打开的
    elseif connection.state = asStateClosed then
       '数据库的当前状态是关闭的
    end if
      

  7.   

    谢谢回复![can't connectted]是什么意思?这个函数是判断连接字符串是否有效呀。
      

  8.   

    这个问题加分了,见http://www.csdn.net/expert/topic/900/900702.xml?temp=.3095514
      

  9.   

    这个问题加分了,见
    http://www.csdn.net/expert/topic/900/900702.xml?temp=.3095514
      

  10.   

    用TIMER 控件定时访问数据库,
    不成功的一次就为断开的状态。
    输出相关信息。
      

  11.   

    connection的属性state当(state and 0)=true,关闭
      (state and 1)=true,打开
      (state and 2)=true,正在打开
      (state and 4)=true,查询正在进行中
      (state and 8)=true,正在执行或打开对象(因此对象不可用)                   WWW
                       @-@
                        ^
      

  12.   

    网络物理连接断开,connection.state检测不到。