I am trying to handle the issue of disconnection in my application for a Hand Held with Windows CE v5 in Visual Basic 2005. I am dealing with it in a routines module, which verifies the status of the connection. If this connection is closed, the user is informed and a re-connection process is initiated; once the process is finished, the application is sent to close, but the Application.Exit () instruction does not terminate the application. Here my code:
Method in routines:
Public Sub fbReconecta()
Dim x As Integer
If ConSql.State = ConnectionState.Closed Then
If ConSql.State = ConnectionState.Closed Then
If MsgBox("Se esta recuperando la conexión, si esta demorando ud. puede cerrar la " & _
" aplicación. ¿Desea Cerrarla?", MsgBoxStyle.Question + vbYesNo + vbDefaultButton2) = vbNo Then
For x = 0 To 20
BDAbrir(ConSql, , PServidorDB, PBaseDatos, PUserDB, PUserPwdDB)
Next
If ConSql.State = ConnectionState.Closed Then
MsgBox("No se pudo recuperar la conexión, la aplicación se cerrará", MsgBoxStyle.Critical, "Atención")
Application.Exit()
End If
Else
Application.Exit()
End If
End If
End If
End Sub
Call to Method
Catch ex As Exception
sqldata.Close()
fbReconecta()
If ConSql.State = ConnectionState.Closed Then
Application.Exit()
Else
GoTo Reintenta
End If
End Try
If you had any idea how to resolve the issue of closing the application and cancel the other instructions, I would appreciate it too