读取
protectedvoidpage _ load (对象发送器,事件发生器) ) ) ) ) ) ) ) )。
{
CheckLogin MyChk=new CheckLogin (;
title.InnerHtml='b数据库连接配置/b ';
if (! IsPostBack )
{
configuration config=system.web.configuration.webconfigurationmanager.openwebconfiguration (
string my connect=config.connection strings.connection strings [ ' myapp.properties.settings.SQL connnect setting ' ].TTT
string[] arycon=myConnect.Split (';' );
int i,li_index;
for(I=0; i arycon.Length; I )
{
if (ary con [ I ].index of (数据源)-1 ) ) )。
{
Li_index=Arycon[I].indexof('=';
textbox1. text=ary con [ I ].substring (Li _ index1);
}
if (ary con [ I ].index of (初始目录)-1 ) )。
{
Li_index=Arycon[I].indexof('=';
textbox2. text=ary con [ I ].substring (Li _ index1);
}
if(Arycon[I].indexof(userid )-1 ) )
{
Li_index=Arycon[I].indexof('=';
textbox3. text=ary con [ I ].substring (Li _ index1);
}
if(Arycon[I].indexof('password ' )-1 ) ) ) )。
{
Li_index=Arycon[I].indexof('=';
textbox4. text=ary con [ I ].substring (Li _ index1);
}
}
}
}修正
protectedvoidbutton1_ click (对象发送器,事件发生器) ) ) ) ) ) ) ) ) )。
{
string ls _ new string='数据源=' textbox1. text.trim '; 初始目录=' textbox2. text.trim '; 永久安全信息=true; User ID=' TextBox3.Text.Trim () ); Password=' TextBox4.Text.Trim (;
configuration config=system.web.configuration.webconfigurationmanager.openwebconfiguration (
string csname=' myapp.properties.settings.SQL connect setting ';
cs section.connection strings [ csname ].connectionstring=ls _ new string;
config.save (configuration savemode.modified;
//IIS重新启动
}
}转载于:https://www.cn blogs.com/Leo Tian/archive/2008/12/02/1346004.html