c# - Configuration Manager is not saving in app.config -


i have app.config :

<?xml version="1.0"?> <configuration> <configsections> </configsections> <connectionstrings>   <add name="conexx" connectionstring="data source=192.168.1.2 ;initial catalog   =ifdcontroladoria3 ;uid =sa;pwd = admin2012" providername="system.data.sqlclient" /> </connectionstrings> <startup><supportedruntime version="v4.0"   sku=".netframework,version=v4.0,profile=client"/></startup></configuration> 

i m trying update connectring c# :

  coneydstr = @"data source=" + combobox1.text + ";initial catalog =" + cmbbancos.text + ";uid =" + txtusuario.text + ";pwd =" + txtpassword.text;         try          { coneyd.connectionstring = coneydstr;             coneyd.open();             funciona = true;            lblstringsalida.text = coneydstr;          }          catch (exception ex)         {  messagebox.show(coneyd + ex.message.tostring());  }          if (funciona)         {            configuration config = configurationmanager.openexeconfiguration(configurationuserlevel.none);           config.connectionstrings.connectionstrings["conexx"].connectionstring = coneydstr;           config.save();            }  

but not making update ,

 using system.configuration; 

is in header , reference , wrong?????

i have write wrong problem, want store connectionstring somewhere maybe app.config or other file , , change string in install or when server or user changes. right way this???

well, problem you're looking @ wrong file. @ config.filepath property in debugger - tell exactly file you're dealing here , now.

when run code in visual studio, code change yourapplication.exe.config inside project\bin\debug directory - not change app.config in project directory!

so when run code - after config.save(), have @ project's \bin\debug directory , config file inside there - values updated?


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -