View Full Version : SQL Login connection strings

03-11-2008, 10:56 AM
I am installing a web application that is backed by a SQL database. I have an MSI Project with InstallScript. These forums have shown me how to properly customize the SQL Login dialog, duplicate it (I have multiple DSNs) and write out properties to an XML File. Thanks to Christopher Painter, klcounte and rsinclair for getting me through the XML file stuff!

http://community.macrovision.com/showthread.php?t=168242&highlight=editing+web.config and http://community.macrovision.com/showthread.php?t=143739 have great info on the topics.

I am now trying to figure out the cleanest way to alter my connection strings based on the Windows vs. SQL authentication radio buttons.

I created a custom action, CreateMainDSN, that is attached to the SQL Login Next button. This action sets a SQL_LOGIN_DSN property based on values from the SQLLogin dialog. I then write out SQL_LOGIN_DSN to a web.config file using the XML File Changes. Everything works fine when I assume a specific type of authentication, but I can't figure out an easy way to handle this:

if (Windows authentication)
SQL_LOGIN_DSN = "String 1"
SQL_LOGIN_DSN = "String 2"

I can use InstallScript or VBScript, but assume there is a better way to do this. Does anybody have advice on how to properly handle conditional logic when setting a property via custom actions?

Christopher Painter
03-19-2008, 06:08 PM
Use 2 CA's with mutually exclusive conditional expressions. If string 1 evaluates to true, set the DNS property to one formated value otherwise set it to a different formated value.