Looking in "Microsofts Access Developers Guide to SQL Server" there is a recommendation and code for a Global ADO Connection Object.
As I do not want people to have to log in I have taken out the login stuff and so far I have the following.
This is initiated at start up. Sometimes the program just stops here and does not go any further, no error message nothing it just stops. I assume that it has to do with the SQL Server settings as well which is why I have put it in this forum section.
What could this be, how can I trap this error and/or how can I fix it?
Sometimes while using this connection, if it does not exist (for whatever reason) I get a window to re-enter the SQL Server user name and password (with the password being blank) how can I capture this event and stop it from asking the user for the login information again.
With this second question I am not sure if it is as a result of this connection or as a result of the linked tables - which currently use a DSN File.
As I do not want people to have to log in I have taken out the login stuff and so far I have the following.
Code:
Option Compare Database
Option Explicit
Public Const LUT_PROVIDER As String = "SQLOLEDB.1"
Public Const LUT_DATA_SOURCE As String = "servername"
Public Const LUT_INITIAL_CATALOG As String = "dbname"
Public Const LUT_USER_ID As String = "username"
Public Const LUT_PASSWORD As String = "PW"
Public Function OpenConnection() As Boolean
On Error GoTo HandleError
Dim boolState As Boolean
If gcnn Is Nothing Then
Set gcnn = New ADODB.Connection
End If
If gcnn.State = adStateOpen Then
boolState = True
Else
gcnn.ConnectionString = "Provider=" & LUT_PROVIDER & "; Data Source=" & LUT_DATA_SOURCE & ";Initial Catalog=" & LUT_INITIAL_CATALOG & "; User ID=" & LUT_USER_ID & ";Password=" & LUT_PASSWORD
gcnn.Open
If gcnn.State = adStateOpen Then
boolState = True
End If
End If
OpenConnection = boolState
ExitHere:
Exit Function
HandleError:
OpenConnection = False
Err.Raise Err.Number, Err.source, Err.Description, Err.HelpFile, Err.HelpContext
Resume ExitHere
End Function
What could this be, how can I trap this error and/or how can I fix it?
Sometimes while using this connection, if it does not exist (for whatever reason) I get a window to re-enter the SQL Server user name and password (with the password being blank) how can I capture this event and stop it from asking the user for the login information again.
With this second question I am not sure if it is as a result of this connection or as a result of the linked tables - which currently use a DSN File.