*应用程序配置文件的常用写法和调用

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

<configuration>

    <configSections>

    </configSections>

    <connectionStrings>

<add name="DataBaseOwner" connectionString="dbo" />

<add name="MySchoolConnectionString" connectionString="Data Source=.;Initial Catalog=MySchool;User ID=sa;Password=123456"

providerName="System.Data.SqlClient" />

    </connectionStrings>

</configuration>







#region Private Members

        //从配置文件中读取数据库连接字符串
        private readonly string connString = ConfigurationManager.ConnectionStrings["MySchoolConnectionString"].ToString();
        private readonly string dboOwner = ConfigurationManager.ConnectionStrings["DataBaseOwner"].ToString();
        #endregion
posted @ 2008-10-20 02:11  Edward Xie  阅读(243)  评论(0编辑  收藏  举报