Results 1 to 5 of 5

Thread: updating app.config connection string at runtime [* Resolved *]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2001
    Posts
    1,331

    Resolved 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width