Hi there
I am using the following function to check if the ODBC-connection is available each time the user runs the application. A few weeks it started to give wrong results: when i run the function right after starting the application it sometimes (not always) faces an odbc-connection error, telling me I'm offline, but I'm not. I tried using different users and passwords, same issues. Strange enought, it has no problems opening linked tables with the same combination of user & password.
Any ideas? Any other ways of checking for an ODBC-connection more gracefully?
qqq
===================================
Public Function FtnIsOnline() As Boolean
'to determine whether there's a connectiont to the SQL server or not
On Error GoTo ErrorHandler
Dim wrkODBC As Workspace
Dim conPubs As Connection
' Create ODBCDirect Workspace object.
Set wrkODBC = CreateWorkspace("NewODBCWorkspace", "admin", "", dbUseODBC)
Set conPubs = wrkODBC.OpenConnection("c", dbDriverNoPrompt, , "ODBC;DATABASE=MyDatabase;DSN=MyConnection;UID=MyUser;PWD=MyPassword")
conPubs.Close
FtnIsOnline = True
GoTo Exiter
ErrorHandler:
If Err.number = 3146 Or Err.number = 3151 Then
FtnIsOnline = False
GoTo Exiter
Else
' ... normal error routine
End If
Exiter:
Set wrkODBC = Nothing
Set conPubs = Nothing
End Function
===================================
MySQL backend, tables linked using MySQL ODBC 5.1 Driver, front end running Access 2002 on WinXP
I am using the following function to check if the ODBC-connection is available each time the user runs the application. A few weeks it started to give wrong results: when i run the function right after starting the application it sometimes (not always) faces an odbc-connection error, telling me I'm offline, but I'm not. I tried using different users and passwords, same issues. Strange enought, it has no problems opening linked tables with the same combination of user & password.
Any ideas? Any other ways of checking for an ODBC-connection more gracefully?
qqq
===================================
Public Function FtnIsOnline() As Boolean
'to determine whether there's a connectiont to the SQL server or not
On Error GoTo ErrorHandler
Dim wrkODBC As Workspace
Dim conPubs As Connection
' Create ODBCDirect Workspace object.
Set wrkODBC = CreateWorkspace("NewODBCWorkspace", "admin", "", dbUseODBC)
Set conPubs = wrkODBC.OpenConnection("c", dbDriverNoPrompt, , "ODBC;DATABASE=MyDatabase;DSN=MyConnection;UID=MyUser;PWD=MyPassword")
conPubs.Close
FtnIsOnline = True
GoTo Exiter
ErrorHandler:
If Err.number = 3146 Or Err.number = 3151 Then
FtnIsOnline = False
GoTo Exiter
Else
' ... normal error routine
End If
Exiter:
Set wrkODBC = Nothing
Set conPubs = Nothing
End Function
===================================
MySQL backend, tables linked using MySQL ODBC 5.1 Driver, front end running Access 2002 on WinXP