I'm using the following code that is run from my Autoexec macro to make the ODBC connection.
'Name : CreateDSNConnection
'Purpose : Create a DSN to link tables to SQL Server
'Parameters
' sServer: Name of SQL Server that you are linking to
' sDatabase: Name of the SQL Server database that you are linking to
' sUsername: Name of the SQL Server user who can connect to SQL Server, leave blank to use a Trusted Connection
' sPassword: SQL Server user password
Public Function CreateDSNConnection(sServer As String, sDatabase As String, sUsername As String, sPassword As String) As Boolean
Dim sConnect As String
On Error GoTo CreateDSNConnection_Err
If Len(sUsername) = 0 Then
'//Use trusted authentication if stUsername is not supplied.
sConnect = "Description=DBTraining" & vbCr & "SERVER=" & sServer & vbCr & "DATABASE=" & sDatabase & vbCr & "Trusted_Connection=Yes"
Else
sConnect = "Description=DBTraining" & vbCr & "SERVER=" & sServer & vbCr & "DATABASE=" & sDatabase
End If
DBEngine.RegisterDatabase "DBTraining", "SQL Server", True, sConnect
'Add error checking.
CreateDSNConnection = True
Debug.Print "Connection made"
Exit Function
CreateDSNConnection_Err:
CreateDSNConnection = False
MsgBox "CreateDSNConnection encountered an unexpected error: " & Err.Description, vbCritical, "Unexpected Error!"
End Function
Pretty standard stuff...but it seems that the ODBC connection is always setup as using Windows auth and I need it setup to use SQL Server auth. I've tried dropping in the UID= and PWD=, but it still tries to use Windows.