PDA

View Full Version : How to set the ODBC DSN name by user input?



mindone
05-19-2006, 05:42 AM
Hi,

I want to ask the installing user for the name of the ODBC DSN to be created during the setup.

Is it possible to do that?


Thanks

bhagelin
05-19-2006, 01:50 PM
Yes, it is possible but it is a bit more difficult than allowing the user to enter a DSN attribute or property. To set the DSN name, you'll have to edit the target system's registry.

If you're creating this DSN during install, create the DSN first with a placeholder name such as "DSN1." After that DSN is created, you can edit its registry values with InstallScript (if you're using InstallScript MSI project type). You'll have to change the registry key name from HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBC.INI\DSN1 to HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBC.INI\WHATEVER. You'll also have to change the key value located in HKEY_LOCAL_MACHINE\\SOFTWARE\\ODBC\\ODBC.INI\ODBC File DSN from DSN1 to WHATEVER.

That's the best way I've found to create a dynamic DSN name. If you're using Basic MSI project then you may have to use some sort of custom action with code in it that edits the registry in the manner I've described.