sdm10101
Posts: 35
Joined: Wed May 06, 2009 2:13 pm

ODBC - Dynamically set

I'm trying to create an installer that will name an ODBC depending upon the "instance" being installed.
i.e. User selects instance during installation, say instance 2, then instance gets added to ODBC details.

What I want is for the ODBC to be called MyODBC_2.

I've tried naming it MyODBC_[INSTANCE_PROPERTY], but this does not work.
I get ODBC error 9: Invalid DSN, Verify that the file MyODBC_[INSTANCE_PROPERTY] exists...

It should not exist, as I'm creating it during the installation.

What I think I need is the property that I can set during the installation for the ODBC's name.

Thanks
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: ODBC - Dynamically set

Hello,

I'm afraid this is a Windows Installer limitation. Please keep in mind that the ODBCDriver table columns doesn't support formatted type, therefore you cannot use a property reference in the fields from "Driver Properties" pane.

However, in order to achieve what you want you can configure your ODBC driver using registry value. Every ODBC drivers installation creates at least the following mandatory registry entries:
  • Path: SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers
    Name: <Driver Name>
    Type: REG_SZ
    Data: Installed

    Path: SOFTWARE\ODBC\ODBCINST.INI\<Driver Name>
    Name: Driver
    Type: REG_EXPAND_SZ
    Data: <Path_to_driver_dll_file>

    Path: SOFTWARE\ODBC\ODBCINST.INI\<Driver Name>
    Name: Setup
    Type: REG_EXPAND_SZ
    Data: <Path_to_driver_setup_file>

    Path: SOFTWARE\ODBC\ODBCINST.INI\<Driver Name>
    Name: UsageCount
    Type: REG_DWORD
    Data: 1
So, instead of using the "ODBC" page to configure your ODBC driver, you can create the above registry entries (with formatted fields) using our "Registry" page. Also, in order to see what registry entries will be created for your ODBC driver you can configure it using our "ODBC" page, install it and then observe what registry entries will be created under SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers and under SOFTWARE\ODBC\ODBCINST.INI\<Driver Name>. Then, you can create the related registry entries using our "Registry" page.

Also, please keep in mind that if your driver dll file is a 32-bit dll, then the above registry entries should be created under "Wow6432Node" (e.g. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\<Driver Name>).

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
sdm10101
Posts: 35
Joined: Wed May 06, 2009 2:13 pm

Re: ODBC - Dynamically set

Daniel

Sorry, I wasn't quite explicit enough in my original post.
The driver will already be present. I'm installing an ODBC datasource.
Is this possible with dynamic values? Or should I use a registry method similar to what you've already described?

Thanks
sdm10101
Posts: 35
Joined: Wed May 06, 2009 2:13 pm

Re: ODBC - Dynamically set

More info...
It's the name of the Datasource I'd like to set dynamically. I know I can do this with the other values.
sdm10101
Posts: 35
Joined: Wed May 06, 2009 2:13 pm

Re: ODBC - Dynamically set

I have used your registry key idea for my ODBC data source issue.

Thanks
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: ODBC - Dynamically set

You're welcome. I'm glad you got this working.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”