1

I want to save my full path connection string

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;

in my app.config file's connection string section from C# Windows Forms textbox.

Like this:

<connectionStrings>
    <add name="TRN_DB"
         connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;providerName="System.Data.OleDb"/>
</connectionStrings>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Deb Kumer
  • 33
  • 1
  • 5
  • so you want to save/display the connection string to windows form textbox? – Archana David Jan 19 '20 at 17:10
  • What kind of app is this? Windows forms? How is it deployed? – stuartd Jan 19 '20 at 17:19
  • I want to save db provider, db path and password from windows form text box to app.config file. I input the full db path with password like this (Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDB:System Database=system.mdw;User ID=myUsername;Password=myPassword;) in my windows form's textbox and when i click save button it will be save in app.config file. – Deb Kumer Jan 20 '20 at 04:27

1 Answers1

1

hi please check this page

but you can't modify it because it's read only and you get this error

System.Configuration.ConfigurationErrorsException: 'The configuration is read only.'

you can show connectionString in TextBox with this code

var connection = System.Configuration.ConfigurationManager.ConnectionStrings["TRN_DB"].ConnectionString;
Akbar Asghari
  • 613
  • 8
  • 19