比如我在WEB.CONFIG里写
<appSettings>
<add key="dsn" value="Server=.;UID=sa;PWD=198183;DATABASE=uzfc"/>
</appSettings>
我該怎麼寫讓server=   mian.aspx頁面裡的txtbox1的TEXT的內容,求教

解决方案 »

  1.   

    private string conectionstr=System.Configuration.ConfigurationSettings.AppSettings["dsn"].ToString();
      

  2.   

    //*****如果你想要在界面配置数据连接,你可以看一下下面的方法<appSettings>
    <add key="servername" value="localhost"/>
    <add key="database" value="northwind"/>
    <add key="userid" value="sa"/>
    <add key="password" value="sa"/>
    </appSettings>//****然后读取web.config文件就可以了
      

  3.   

    我是想讓數據庫SERVER讓用戶輸入,所以才問怎麼才能等於main.aspx的textbox1值text,text內容自己輸入
      

  4.   

    XmlDocument xDoc=new XmlDocument();
    xDoc.Load(Server.MapPath("web.config"))
    XmlElement elem=xDoc.CreateElement("add"); XmlAttribute attrib=xDoc.CreateAttribute("key"); attrib.Value="ConnectionString";
    elem.Attributes.Append(attrib); attrib=xDoc.CreateAttribute("value");
    attrib.Value="server="+this.txt_servername.Text.Trim()+";uid="+this.txt_uid.Text.Trim()+";pwd="+this.txt_password.Text.Trim()+";database="+this.txt_databasename.Text.Trim()+";max pool size=150";
    elem.Attributes.Append(attrib);
    xDoc.DocumentElement.ChildNodes[2].PrependChild(elem);
    xDoc.Save(Server.MapPath("web.config"));这事根据输入的数据库链接增加一个web.config的键值。可以参考一下
      

  5.   

    那在web.connfig是不是不可寫,上面的樓主你的在甚麼裡面寫的,我是新人不太明白