Arif
Arif

Reputation: 29

How to change App.config file at run time from textbox value?

I have created a project which has App.config file. This App.config file is fixed. I wanna change connectionString at run time using textbox's value.

Here are two textboxes textbox1 & textbox2. I want to input in textbox & when I click the button then does it happen?

How could I do that Exactly?

Here is the sample code of App.config file:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<connectionStrings>

<add name="DBconnection" connectionString="data source=ARIF\SQLEXPRESS;database=Library_Management_System; Integrated Security=SSPI;"/>

</connectionStrings>

</configuration>

Upvotes: 1

Views: 1362

Answers (1)

User2012384
User2012384

Reputation: 4919

If I were you, I will do it this way:

Properties => Settings => Add new Settings (Make sure Scope is "user")

enter image description here

Here's how you set the value of ConnectionString:

enter image description here

Upvotes: 1

Related Questions