连接字符串 属性 尚未初始化 - AppSettings

The connectionstring property has not been initialized - AppSettings

下面是我的连接字符串,我不知道哪里出错了。

<appSettings>

<!-- Default database to use... -->
<add key="Database_default" value="DB_Servername"/>

<!-- Datamart database connection to use -->
<add key="Database_datamart" value="MED_PROD"/>

<!--  Development Datamart Database Server -->
<add key="MED_PROD" value="Initial Catalog=REPORT_MED;Data Source=DB_Servername;UID=app_UID;PWD=******;"/>

<!--  Dev Server - Port Reference-->
<add key="va3fin01" value="Initial Catalog=acc;Data Source=DB_Servername;UID=med_UID;PWD=*******;"/>

<!-- MEDFIN_DEV -->
<add key="MED_DEV" value="Initial Catalog=MED_DEV;Data Source=DB_Servername;UID=med_UID;PWD=********;"/>

 </appSettings>

我无法更改任何后端代码。他们让我换服务器。更改服务器后,我在一个工作应用程序上得到 "The connectionstring property has not been initialized"。如果有任何我只能在 web.config

上处理的事情,请告诉我

请帮忙! 谢谢

已编辑

下面是获取连接字符串的方法。

private void GetConnectionString() 
    {
        string _settingname;

        // if its empty, update it with "default"
        if (this._database.Trim().Length == 0) this._database = "default";

        // get the setting...
        _settingname = ConfigurationSettings.AppSettings["Database_" + this._database];
        if (_settingname == null) 
        {
            throw new Exception("Unable to determine connection settings for specified database.");
        } 
        else
        {
            // retrieve the connection string from the specified database...
            this._ConnectionString = ConfigurationSettings.AppSettings[_settingname];
        }
    }

通常,连接字符串在 connectionstring 标签内 web.config

例如,

<connectionStrings>
   <add name="MED_PROD" connectionString="Initial Catalog=REPORT_MED;Data Source=DB_Servername;UID=app_UID;PWD=******;" providerName="System.Data.SqlClient"/>
   <add name="va3fin01" connectionString="Initial Catalog=acc;Data Source=DB_Servername;UID=med_UID;PWD=*******;" providerName="System.Data.SqlClient"/>
   <add name="MED_DEV" connectionString="Initial Catalog=MED_DEV;Data Source=DB_Servername;UID=med_UID;PWD=********;" providerName="System.Data.SqlClient"/>
</connectionStrings>