如何从文本框的值运行时更改App.config文件? [英] How to change App.config file at run time from textbox value?
问题描述
我创建了具有App.config文件的项目。这App.config文件是固定的。我想改变文本框使用的价值在运行时的ConnectionString
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.
下面是两个文本框 TextBox1中
&安培; TextBox2中
。我想在文本框和放大器的输入端;当我点击按钮,然后它会发生?
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?
下面是?App.config文件的示例代码:; XML版本=1.0编码=UTF-8>
Here is the sample code of App.config file:
<
<结构>
<是connectionStrings>
<添加名称=的DbConnection的connectionString = 数据源= ARIF\SQLEXPRESS;数据库= Library_Management_System;集成安全性= SSPI;/>
< /是connectionStrings>
< /结构>
推荐答案
如果我是你,我会做这种方式:
If I were you, I will do it this way:
属性=>设置=>添加新设置(确保范围是用户)
Properties => Settings => Add new Settings (Make sure Scope is "user")
下面是你如何设置的ConnectionString的值:
Here's how you set the value of ConnectionString:
< IMG SRC =http://i.stack.imgur.com/zC0s2.pngALT =在这里输入的形象描述>
这篇关于如何从文本框的值运行时更改App.config文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!