Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. update app.config file at runtime

update app.config file at runtime

Scheduled Pinned Locked Moved Visual Basic
databasesysadminsalestutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    steve_rm
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • S steve_rm

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • C Christian Graus

        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

        S Offline
        S Offline
        steve_rm
        wrote on last edited by
        #3

        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

        T 1 Reply Last reply
        0
        • S steve_rm

          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

          T Offline
          T Offline
          TJO1
          wrote on last edited by
          #4

          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

          S 1 Reply Last reply
          0
          • T TJO1

            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

            S Offline
            S Offline
            steve_rm
            wrote on last edited by
            #5

            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

            D T 2 Replies Last reply
            0
            • S steve_rm

              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

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • S steve_rm

                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

                T Offline
                T Offline
                TJO1
                wrote on last edited by
                #7

                You have gone a bit further than I can help, but try this in VB help... ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/wd_adonet/html/1471f580-bcd4-4046-bdaf-d2541ecda2f4.htm Cheers Tim

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups