How to gracefully handle server connection changes?


Author
Message
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi all,

I have seen cases where after setting a connection to the server using SF Connection Manager, if the server IP address changes or the SF application cannot contact the server an exception will be triggered.

I am currently have code in the AppMain.UnhandledExceptionFound() to trap any SqlClient error and then show the available connection string so the end user can change it if need it.

    Private Shared Sub UnhandledExceptionFound(ByVal e As UnhandledExceptionFoundEventArgs)
        '-- ToDo: add any error logging required.  To prevent the StrataFrame ApplicationErrorForm from showing,
        '   set:
        '   e.Handled = true

        '-- If we get an error with the connection and the user is the Administrator then show the 
        '   the Available Connection Strings
        If e.UnhandledException.Source.IndexOf("SqlClient") > 0 AndAlso Basics.IsAdministrator() Then
            frmSplashScreen.HideSplash()

            ConnectionManager.ShowAvailableConnectionStrings()
            ConnectionManager.SetConnections()

            frmSplashScreen.ShowSplash()
            e.Handled = True
        End If

        '-- email the error to Progytech
        SendErrorMessageViaEmail(e.UnhandledException)

    End Sub

So far the above code is working, but after calling the ConnectionManager.SetConnections() the program exit with another error, then after running the 2nd time, it will use the corrected connection string.
Is anybody here handling this kind of situation differently?  Any suggestion on how to do this more graceful instead of just crashing the application?



Edhy Rijo

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search