Drew,
If the DSN is to connect to a SQL server database, there is an example at
The access Web (
http://www.mvps.org/access/tables/tbl0014.htm).
If you are creating DSNs for Oracle, I use the following.
Good luck,
Bruce
------------------------------------
Function fnCreateDSN(sDSN, sServerName, sDatabase, sUserID, sPassword)
'Creates a user DSN to an Oracle database, replacing any existing DSN by
that name
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
'This creates a user DSN, perhaps HKLM would create system DSN
Const cRegKey1 = "HKCU\Software\ODBC\ODBC.INI\"
Const cRegKey2 = "HKCU\Software\ODBC\ODBC.INI\ODBC Data Sources\"
Const cRegKey3 = "HKLM\Software\ODBC\ODBCINST.INI\Oracle ODBC Driver\"
Dim sRegKey1
sRegKey1 = cRegKey1 & sDSN & "\"
'Delete the old key if there is one
On Error Resume Next
WshShell.RegDelete sRegKey1
'Find the ODBC driver location from the registry setting
Dim strDriverLoc
strDriverLoc = WshShell.RegRead(cRegKey3 & "Driver")
If strDriverLoc <> "" Then
WshShell.RegWrite sRegKey1 & "Driver", strDriverLoc
Else
MsgBox ("Oracle ODBC Driver not found in registry")
End If
WshShell.RegWrite sRegKey1 & "ServerName", sServerName
WshShell.RegWrite sRegKey1 & "Database", sDatabase
WshShell.RegWrite sRegKey1 & "UserID", sUserID
WshShell.RegWrite sRegKey1 & "Password", sPassword
'WshShell.RegWrite sRegKey1 & "LOBS", "T"
'WshShell.RegWrite sRegKey1 & "FailOver", "T"
'WshShell.RegWrite sRegKey1 & "ResultSets", "T"
'Make the DSN available to the ODBC manager
WshShell.RegWrite cRegKey2 & sDSN, "Oracle ODBC Driver"
Set WshShell = Nothing
End Function