Extract Connection String from SQLServerConnectionDlg - Advanced Installer Community
zeiddev
Posts: 103
Joined: Sat Aug 10, 2013 12:30 am

Extract Connection String from SQLServerConnectionDlg

There does not appear to be that much documentation or information about the SQLServerConnectionDlg dialog. I have now used to successfully create a database table. However I would also like to use it to update the .NET config file with the connection string that would have been used on using the dialog.

I can see how you can update the xml config file based on properties and one one would be to somewhat tediously compile the connection string myself but then I would have to take into consideration the different permutations of values entered into the SQLServerConnectionDlg. I was wondering if the connection string is exposed as a property that I could make use of?
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Extract Connection String from SQLServerConnectionDlg

Hello,

The whole connection string is not saved into an installer property unless you don't explicitly do this. For instance you can use a public property (e.g. MY_CONNECTION_STRING) which will be set to the entire connection string when clicking the [Next] button from SQLServerConnectionDlg. Just select the [Next>] button and in its "Published Events" list add the following event:
  • Event: Set installer property value
    Property: MY_CONNECTION_STRING
    Argument: Driver=[\{]SQL Server[\}];Server=[SERVER_PROP];Port=[PORT_PROP];Uid=[USERNAME_PROP];Pwd=[PASSWORD_PROP];Database=[DATABASE_PROP];
Then, you can use the MY_CONNECTION_STRING property to update your XML config file.

Also, you can take a look on our "Set SQL connection authorization type" article which should be useful for you too.

Let us know if this helped.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
zeiddev
Posts: 103
Joined: Sat Aug 10, 2013 12:30 am

Re: Extract Connection String from SQLServerConnectionDlg

That is perfect, thank you.

It would be great if the documentation were updated to cover the SQLServerConnectionDlg. I added two published events to determine the connection string when the trusted connection box was checked and one for when it was not.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Extract Connection String from SQLServerConnectionDlg

You're always welcome.

We'll try to improve our documentation in what regards the "SQLServerConnectionDlg" dialog. Thank you for your suggestion.

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

Return to “Common Problems”