|
-
Sep 25th, 2006, 09:45 AM
#1
Thread Starter
Frenzied Member
updating app.config connection string at runtime [* Resolved *]
Hello
I am using my.settings to create a application scope connection string.
The customer would like to change this if they want to connect to another database, and this should update the app.config file with the updated connection string.
My problem I have into the setting and create a connection string (easy). But I don't know and can't find out to update and save the new connection string.
My.Settings.cnnString = "This is example connection" 'Error read-only property
I am using .net 2005
Can anyone help,
I got this code and it seem it would work. However, there is a problem with the code. I get a "Object reference not set to an instance of an object."
Here my code.
Code:
Dim config As Configuration.Configuration = Configuration.ConfigurationManager.OpenExeConfiguration(Configuration.ConfigurationUserLevel.None)
config.ConnectionStrings.ConnectionStrings("ServiceMasterConnectionString").ConnectionString = "This is new connection " 'Error -
config.Save()
Thanks in advance,
Steve
Last edited by steve_rm; Sep 26th, 2006 at 02:57 AM.
steve
-
Sep 25th, 2006, 09:51 AM
#2
Re: updating app.config connection string at runtime
You can't update the .config file, but you can store your settings in another xml file which you can update and read from as you please.
-
Sep 25th, 2006, 05:52 PM
#3
Re: updating app.config connection string at runtime
This is a duplicate post AND it's in the wrong forum.
-
Sep 26th, 2006, 02:56 AM
#4
Thread Starter
Frenzied Member
Re: updating app.config connection string at runtime
-
Sep 26th, 2006, 03:12 AM
#5
Re: updating app.config connection string at runtime [* Resolved *]
New information. I like it. I would have liked it better in original thread in the proper forum though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|