|
|||||||
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Frenzied Member
Join Date: Dec 01
Posts: 1,321
![]() |
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 |
|
|
|
|
|
#2 |
|
.NUT
Join Date: May 05
Location: Sydney, Australia
Posts: 54,913
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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, 2008, 2009, 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 | C# (ForumAccount has translated some of my VB submissions to C#) My Blog: Defining and Raising Custom Events | Manipulating GDI+ Drawings | Using Parameters in ADO.NET |
|
|
|
|
|
#3 |
|
Frenzied Member
Join Date: Dec 01
Posts: 1,321
![]() |
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 |
|
|
|
|
|
#4 |
|
.NUT
Join Date: May 05
Location: Sydney, Australia
Posts: 54,913
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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, 2008, 2009, 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 | C# (ForumAccount has translated some of my VB submissions to C#) My Blog: Defining and Raising Custom Events | Manipulating GDI+ Drawings | Using Parameters in ADO.NET |
|
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|