Believe me, I've tried!
I'm working with a SQL Server 7 backend and an Access 97 frontend ... and an Excel 97 frontend too.
I was able to register the DSN without UID and PWD, and Access worked fine, but it seems Excel needs the UID & PWD to connect.
This is what I've got that works (without UID & PWD):
I've tried adding
I've tried adding a
at the end.
I've tried using the full ODBC connection string.
I've tried using
instead of
I've also tried using the
with
None of these attempts were able to create the DSN.
It also appears that on every forum I've searched no solution has ever been posted to solve/explain this.
If anyone can help, or actually knows the answer, I shall shower them with resplendent adulation and reverence, not to mention an expert star.
Hundreds of ways to do things with PC's, and learning new ways every day.
I'm working with a SQL Server 7 backend and an Access 97 frontend ... and an Excel 97 frontend too.
I was able to register the DSN without UID and PWD, and Access worked fine, but it seems Excel needs the UID & PWD to connect.
This is what I've got that works (without UID & PWD):
Code:
'*************************************************
'* Declare Constants
Const DSN = "BERT_Stg"
Const SERVERNAME = "lons000391"
Const DBNAME = "BERT_UAT"
Const DESCRIBE = "BERT STG SQL Database"
Const CONNECTSTRING = "ODBC;DSN=" & DSN & ";DATABASE=" & DBNAME & ";UID=BERT_user;PWD=sesame"
'*************************************************
Function RegisterDSNs()
Dim strAttributes As String
Dim errLoop As Error
strAttributes = "Database=" & DBNAME & _
vbCr & "Description=" & DESCRIBE & _
vbCr & "Server=" & SERVERNAME
'* Update Windows Registry.
On Error GoTo Err_Register
DBEngine.RegisterDatabase DSN, "SQL Server", True, strAttributes
On Error GoTo 0
Exit Function
Err_Register:
'* Notify user of any errors that result from the invalid data.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
Debug.Print "Error number: " & errLoop.Number & " -- " & errLoop.Description
Next
End If
Resume Next
End Function
I've tried adding
Code:
strAttributes = "Database=" & DBNAME & vbCr _
& "Description=" & DESCRIBE & vbCr _
& "Server=" & SERVERNAME & vbCr _
& "UID=BERT_user" & vbCr _
& "PWD=sesame"
I've tried adding a
Code:
vbCr
I've tried using the full ODBC connection string.
I've tried using
Code:
LastUser
Code:
UID
I've also tried using the
Code:
Function SQLConfigDataSource Lib "ODBCCP32.DLL"
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver, strAttributes)
Code:
Private Const vbAPINull As Long = 0
None of these attempts were able to create the DSN.
It also appears that on every forum I've searched no solution has ever been posted to solve/explain this.
If anyone can help, or actually knows the answer, I shall shower them with resplendent adulation and reverence, not to mention an expert star.
Hundreds of ways to do things with PC's, and learning new ways every day.