update app.config file at runtime
-
Hello, I want to be able to update a connection string that I have in my app.config file. This is so that the customer can change the connection to another server or database. Can anyone give me any example code. I am using Visual Basic 2005. Many thanks in advance, Steve
-
Hello, I want to be able to update a connection string that I have in my app.config file. This is so that the customer can change the connection to another server or database. Can anyone give me any example code. I am using Visual Basic 2005. Many thanks in advance, Steve
That's odd - didn't I answer this ? .NET 2005 has a new settings file setup that will save your settings for you.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
That's odd - didn't I answer this ? .NET 2005 has a new settings file setup that will save your settings for you.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
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 vb.net 2005 Can anyone help, Thanks in advance, Steve
-
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 vb.net 2005 Can anyone help, Thanks in advance, Steve
-
I think you may have the cnnString setting variable defined as "Application" scope which is read only. If you change it to "User" scope your error should go away. Make the change in the My Project > Settings tab. Cheers Tim
-
Hello Tim, I have changed the setting from application to user. However, if you select connection string, then you cannot select user. It always defaults to application. Is there another way? Thanks very much, Steve
The only other way is to load the app.config file as an XML Document, make the changes you need to that, then resave the XML Document back over the original config file. You can find more by Googling "read write app.config file[^]". The first link in the list goes to an article right here on CP.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
Hello Tim, I have changed the setting from application to user. However, if you select connection string, then you cannot select user. It always defaults to application. Is there another way? Thanks very much, Steve