Results 1 to 28 of 28

Thread: [RESOLVED] Remote connection: if not whitelisted, takes forever

Threaded View

  1. #15

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    790

    Re: Remote connection: if not whitelisted, takes forever

    Here is my code for this (it is done on Form load):

    Code:
    Private Sub Form_Load()
    Set cn = New ADODB.Connection
        cn.ConnectionString = "string"
        cn.CursorLocation = adUseClient
        cn.ConnectionTimeout = 30
    
        cn.Open , , , adAsyncConnect
        
        Dim lngLoop As Long
        Do While cn.State = adStateConnecting
          Label2.Caption = "Loading... " & Choose(lngLoop Mod 4 + 1, "|", "/", "-", "\")
          Sleep 300
          DoEvents
          lngLoop = lngLoop + 1
        Loop
    
    End Sub
           
    Private Sub cn_ConnectComplete(ByVal pError As ADODB.Error, adStatus _
       As ADODB.EventStatusEnum, ByVal pConnection As ADODB.Connection)
    
       Set rs = New ADODB.Recordset
       rs.Open "SELECT * FROM `mydb`ORDER BY `effective_date` DESC", cn, adOpenDynamic, adLockOptimistic
        
       Label2.Caption = rs.Fields("number")
       
       rs.Close
       cn.Close
    End Sub
    When I run my project, nothing loads for about 15 seconds and I get this error:

    Run-time error '3709':
    The connection cannot be used to perform this operation. It is either closed or invalid in this context.
    ...after I select debug the line "rs.open...." is highlighted.

    I intentionally removed my IP from the whitelist in order to build my connections around this. I was suprised to see that my form did not load right away with the adAsyncConnect

    What am I doing wrong? Thanks.

    I want the form to load right away, have label 2 say "loading" as the connection is established. Once connection is established call loaddataincontrols. If the connection times out then do nothing.
    Last edited by chris.cavage; Jul 17th, 2009 at 08:51 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width