nilarya
Posts: 2
Joined: Mon Jul 15, 2013 8:23 am

update web.config connectionstring

Hi,
I am trying to create an installer for a Silverlight web application.

a. the installer will search for the available MSSQL database server and create a connection to it. I have created a custom action to find all servers and then connect to the selected server using windows/Authentication and or SQL server Authentication. I have a property where I am storing the connection string.

b. I have a sql script which then runs and creates a new database, Login and user account in that server.

c. in my web.config, I then have to write the value of the server in the connectionstring property.

I am able to achieve steps a and b. But I am not finding any good examples to achieve step c.

Can anyone please point me to an article if it is there somewhere? It would be great if you can send me a sample project which demonstrates how to do this.

Thanks,

Nilarya
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: update web.config connectionstring

Hi Nilarya and welcome to Advanced Installer forums.

If your "web.config" file is included in your project, you can open it, select the node where you want to store the "connectionstring" property to, go in the "Attributes" tab and add a new attribute like in the example below:
  • Name: connection_string (any name you want)
    Value: [connectionstring]
    (where "connectionstring" is the name of your property)
Let us know if this helped, otherwise give us more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
nilarya
Posts: 2
Joined: Mon Jul 15, 2013 8:23 am

Re: update web.config connectionstring

Thank you.

I am able to add required properties in the webconfig now.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: update web.config connectionstring

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

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
RubenG
Posts: 10
Joined: Thu Jun 26, 2014 6:10 pm

Re: update web.config connectionstring

Hi, I'm trying to do the same thing. I have an Installer property called SqlConnectionString with this value

Code: Select all

Data Source=[|SERVER_PROP];Initial Catalog=[|DATABASE_PROP];User ID=[|USERNAME_PROP];Password=[|PASSWORD_PROP]
, when I run the installer what I get is

Code: Select all

Data Source=;Initial Catalog=;User ID=;Password=
What am I doing wrong?
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: update web.config connectionstring

Hi Ruben and welcome to Advanced Installer forums,

This is happening because you are using a reference to a PseudoFormatted data type. Please note that you need to use a reference to a Formatted data type.

Please keep in mind that properties referenced by PseudoFormatted data types are resolved at build time while properties referenced by Formatted data types are resolved at runtime.

So, can you please try to see the following statement:

Code: Select all

Data Source=[SERVER_PROP];Initial Catalog=[DATABASE_PROP];User ID=[USERNAME_PROP];Password=[PASSWORD_PROP]
You can also take a look on the How to test SQL connection parameters? article which may be useful to you.

Please let us know if you have other questions.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
RubenG
Posts: 10
Joined: Thu Jun 26, 2014 6:10 pm

Re: update web.config connectionstring

Hi Dan,

I've already changed the statemet to Formatted type, and then it writes in my file the exact text of the property.

I don't know which is the issue with this.

Thanks a lot.
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: update web.config connectionstring

Hi Ruben,

In order to have a better view about this, please send us the .AIP (project file) if it doesn't contain any confidential information or a similar, simplified project reproducing the issue to support at advancedinstaller dot com so we can investigate this.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”