Results 1 to 7 of 7

Thread: Why doesn't my onError work? (Resolved)

Threaded View

  1. #1

    Thread Starter
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Why doesn't my onError work? (Resolved)

    I'm writing a word plugin which connects to a back end database. I've got the following code:-

    Code:
    On Error GoTo connErr61
        mConn.Open "Provider=SLXNetwork.1;User ID =" & mUserID & ";password=" & mPassword & ";Data Source = " & mDB & ";Extended Properties=""SLX Server=" & mServer & ";ADDRESS=localhost;Type=ODBC;PORT=" & mPort & """"
        MsgBox "open succeeded"
        mConn.CursorLocation = adUseClient
    Exit Sub
    connErr61:
        MsgBox "open failed"
        If MsgBox("Database connection failed. Check configuration? (Cancel will exit)", vbOKCancel, "Connection Error") = vbOK Then
            configure
        Else
            Err.Raise 100, "Config.Connect", "Connection Failed"
        End If
    End Sub
    The idea is that if the connection fails I give the user the option to configure the connection (via the configure method) or not to bother. If the user doesn't bother then the app should raise an error which will be caught at the top level and exit gracefully.

    The trouble is that if I give it an invalid password I get a runtime error on the mConn.open line and the app bombs out immediately. Neither the "open succeeded" or "open failed" message appears and, more importantly, the code which lets the user reconfigure doesn't fire. As a result, once there's a bad password the user can't get into the app at all.

    Shouldn't my "onError GoTo connErr61" force execution in to the connErr61 block?
    Last edited by FunkyDexter; Aug 9th, 2005 at 08:48 AM.

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