What odbcconf.exe command line can I use to change the path to the MS Access .mdb file for an already existing System DSN?
+1
A:
You would have to do it by changing the registry. Something along the lines of this example taken from the net that I have used before
rem -----Author: Jim Michaels
rem -----copy the drivers where all good little ODBC drivers go
if errorlevel 1 goto bye
copy myodbcd.dll C:\WINDOWS\SYSTEM
if errorlevel 1 goto bye
rem ----create a .REG file to make registry entries
echo REGEDIT4>myodbc.reg
echo.>>myodbc.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\MySQL]>>myodbc.reg
echo "APILevel"="2">>myodbc.reg
echo "ConnectFunctions"="YYN">>myodbc.reg
echo "Driver"="C:\\WINDOWS\\SYSTEM\\myodbc.dll">>myodbc.reg
echo "DriverODBCVer"="02.50">>myodbc.reg
echo "FileExtns"="*.txt">>myodbc.reg
echo "FileUsage"="0">>myodbc.reg
echo "Setup"="C:\\WINDOWS\\SYSTEM\\myodbc.dll">>myodbc.reg
echo "SQLLevel"="1">>myodbc.reg
echo.>>myodbc.reg
echo [HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers]>>myodbc.reg
echo "MySQL"="Installed">>myodbc.reg
echo.>>myodbc.reg
rem -----install the registry entries by executing the .REG file
start /wait myodbc.reg
rem ----clean up after we are done installing
del myodbc.reg
:bye
If you look at your existing DSN config in the registry then you will get an idea of how to modify the code to suit your situation
Kevin Ross
2010-08-06 07:18:59
Perfect! I found the exact place that the .mdb path was stored, in the REG_SZ value "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\\[System DSN Name]\DBQ". Thank you!
2010-08-06 13:38:05
I think it's crazy to modify the registry for something that is an outside dependency that you don't even need in the first place, i.e., you don't need a DSN at all.
David-W-Fenton
2010-08-06 18:00:41
For better or for worse, my app-under-test already uses DSN connections, and I'm not in a position to change that code. I just want to switch out the .mdb file, without the app even knowing, to test the app using different datasets. In the test scripts I'm writing, I'm not even establishing a connection, so DSN vs. DSN-less doesn't really come into play for me here.
2010-08-06 19:09:31
If you're using the DSN, you're establishing a connection, just not necessarily in code.
David-W-Fenton
2010-08-07 22:56:24