Hello,

I have a webSetup program for installing my web service and I want to change the connection string. As the user will not know the connection string until they install the program. So during the installation the connection string has to be updated.

I have included a installer class and have used the interface with 4 textboxes to get the user input.

The code below works if you know where the web config will be before hand. However, the user will only know this when the program is installed.

Is there a method that will give you this information?

Many thanks in advance,

Steve

Code:
Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)

        Dim database As String = Me.Context.Parameters.Item("DBName")
        Dim server As String = Me.Context.Parameters.Item("Server")
        Dim userID As String = Me.Context.Parameters.Item("UserID")
        Dim pwd As String = Me.Context.Parameters.Item("pwd")
        Dim cnnStr As String = String.Empty

        Dim fileMap As New ExeConfigurationFileMap
        Dim webConfigPath As String = "C:\where can I find where this is being installed?"

        fileMap.ExeConfigFilename = webConfigPath

        Dim config As System.Configuration.Configuration
        config = System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None)
        cnnStr = config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString

        MsgBox(cnnStr)

        Dim newCnnStr As String
        newCnnStr = String.Format("Data source = {0} database = {1} user ID = {2} pwd = {3}", server, database, userID, pwd)

        MsgBox(newCnnStr)
        config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString = newCnnStr
        config.Save()

    End Sub