To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
Part 10 of the Visual Basic .NET 2010 Express Tutorial Complete!
How to Use the Visual Studio Code Analysis Tool FxCop
Article :: Interview with Andrei Alexandrescu (Part 3 of 3)
Introducing Visual Studio LightSwitch
Visual Studio LightSwitch Beta 1 is Available



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Display Modes
Old Apr 20th, 2007, 04:26 AM   #1
steve_rm
Frenzied Member
 
Join Date: Dec 01
Posts: 1,324
steve_rm is an unknown quantity at this point (<10)
Resolved [RESOLVED] [2005] Finding the path of a file during installing

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
__________________
steve
steve_rm is offline   Reply With Quote
Old Apr 20th, 2007, 04:29 AM   #2
jmcilhinney
.NUT
 
jmcilhinney's Avatar
 
Join Date: May 05
Location: Sydney, Australia
Posts: 61,542
jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)
Re: [2005] Finding the path of a file during installing

You know the path of your executable from the [TARGETDIR] installer variable. Pass that to your InstallerClass object and then use the OpenExeConfiguration method.
__________________

2007-2010

Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (Nullable Data Extensions *NEW*) (Serial Code TextBox *NEW*) | C# (ForumAccount has translated some of my VB submissions to C#)
My Blog: Defining and Raising Custom Events | Using Parameters in ADO.NET | Keyboard Events *NEW*
jmcilhinney is online now   Reply With Quote
Old Apr 24th, 2007, 01:26 AM   #3
steve_rm
Frenzied Member
 
Join Date: Dec 01
Posts: 1,324
steve_rm is an unknown quantity at this point (<10)
Re: [2005] Finding the path of a file during installing

Thanks Jmc,

That really worked.

However, I am just wondering instead of using the dialog boxes that the setup gives you to add to the installation. The one I am using only allows you to have up to 4 text boxes.

Is it possible to be able to create your own and add them instead. I would like to customize my installation a little bit more and user interface does not give me that much functionality.

Many thanks for any suggestions,

Steve
__________________
steve
steve_rm is offline   Reply With Quote
Old Apr 24th, 2007, 01:32 AM   #4
jmcilhinney
.NUT
 
jmcilhinney's Avatar
 
Join Date: May 05
Location: Sydney, Australia
Posts: 61,542
jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)jmcilhinney has a reputation beyond repute (3000+)
Re: [2005] Finding the path of a file during installing

It's not an ideal solution because it makes for a less consistent interface but you can accomplish pretty much anything you want with custom actions. It would have been nice if VS provided a facility to link your own controls into the actual setup wizard UI but it's not that powerful unfortunately.
__________________

2007-2010

Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (Nullable Data Extensions *NEW*) (Serial Code TextBox *NEW*) | C# (ForumAccount has translated some of my VB submissions to C#)
My Blog: Defining and Raising Custom Events | Using Parameters in ADO.NET | Keyboard Events *NEW*
jmcilhinney is online now   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:23 AM.





Acceptable Use Policy

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.