日期:2014-05-19  浏览次数:20743 次

Winform下APP.config问题
有2   个project

project1--取数据---> project2
说明:project1通过project2取数据
project1为主程式,project2专用处理数据,且生成为类库

project2中有一个App.config:
<?xml   version= "1.0 "   encoding= "utf-8 "   ?>
<configuration>
    <appSettings>
        <add   key= "ConnectionString "   value= "Data   Source=KYLEYUAN;Initial   Catalog=WiseChamp;User   ID=sa "/>
    </appSettings>
</configuration>
=================可以正常显示网格数据

public   sealed     class   DataAccess
        {
                private   static   string   connectoinString   =   System.Configuration.ConfigurationManager.AppSettings[ "ConnectionString "];
              //此处   connectionString=null;
                private   static     SqlConnection   cnn   =   new   SqlConnection(connectoinString);
}

上面的类中取到的connectionString=null;
如果在project1中传一个connectionString过去,又会多出很多代码来....



------解决方案--------------------
帮顶
------解决方案--------------------
System.Configuration.ConfigurationSettings.AppSettings[ "connectionStrings "]