{"id":5204,"date":"2014-03-30T19:42:44","date_gmt":"2014-03-30T19:42:44","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/fetching-dynamically-updated-connection-string-from-app-config-in-vb-net-collection-of-common-programming-errors\/"},"modified":"2014-03-30T19:42:44","modified_gmt":"2014-03-30T19:42:44","slug":"fetching-dynamically-updated-connection-string-from-app-config-in-vb-net-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/fetching-dynamically-updated-connection-string-from-app-config-in-vb-net-collection-of-common-programming-errors\/","title":{"rendered":"Fetching dynamically updated connection string from app.config in VB.Net-Collection of common programming errors"},"content":{"rendered":"<p>I have a connection string as follows in app.config<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>I have a form called DBLinker where i am giving an option to the user to select some other server and database. For instance i am selecting Server name as &#8220;MAILSERVER&#8221; and database as &#8220;Actual&#8221;. I am overwriting the app.config file using the following code.<\/p>\n<pre><code>Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)\n\nDim mySection As ConnectionStringsSection = DirectCast(config.GetSection(\"CONN\"),ConnectionStringsSection)\nDim conStr As String = \"SERVER=MAILSERVER;DATABASE=Actual;uid=sa;pwd=trial\"\n\nconfig.ConnectionStrings.ConnectionStrings(\"CONN\").ConnectionString = conStr\nconfig.Save(ConfigurationSaveMode.Full)\n\n\nConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name)\n<\/code><\/pre>\n<p>After this code i am trying to open a login form for the application. But when i am trying to access connection string here, it is fetching the former string instead of the updated one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a connection string as follows in app.config I have a form called DBLinker where i am giving an option to the user to select some other server and database. For instance i am selecting Server name as &#8220;MAILSERVER&#8221; and database as &#8220;Actual&#8221;. I am overwriting the app.config file using the following code. Dim [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5204","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5204"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5204\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5204"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5204"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}