Hi All,

I am trying to get databases from the SQL server of other machine (not local) that is in my network, then I am getting some errors even after I mentioned the time out as 30. I need the control shoul come back to my application after the time expires (i.e. after 30 seconds). By telling the server is not up or access denied. So that I can display the error message and not populate the databases combo. Please see the code below.

Code:
Public Function DBList_Retrieve(ByRef cmbDBList As ComboBox, ByVal sServer As String) As String
    
    Dim cnn As ADODB.Connection
    Dim ars As ADODB.Recordset
    Dim sql As String
    Dim iIndex As Integer
    Dim bFound As Boolean
    
    bFound = False
    iIndex = 0
    cmbDBList.Clear
    Set cnn = New ADODB.Connection
    With cnn
    .Provider = "SQLOLEDB"
    .ConnectionTimeout = 0
    .CursorLocation = adUseClient
    .ConnectionString = "SERVER=" & sServer & ";uid=sa;INITIAL CATALOG=master"
    .Open
    End With
    sql = "select * from sysdatabases"
    Set ars = cnn.Execute(sql)
    Do Until ars.EOF
    cmbDBList.AddItem ars!Name
    If ars!Name = "master" Then
        bFound = True
    End If
    If bFound = False Then
       iIndex = iIndex + 1
    End If
    
    ars.MoveNext
    Loop
    cnn.Close
    DBList_Retrieve = "master"
    cmbDBList.ListIndex = iIndex
    
End Function
Please suggest how can I get?

Thanks,
Narayana Murty.