0
以下は接続文字列ですが、どこがエラーになるのかわかりません。connectionstringプロパティが初期化されていません - 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>
バックエンドコードを変更することはできません。彼らは私にサーバーの変更を依頼しました。サーバーを変更した後、動作中のアプリケーションで「connectionstringプロパティが初期化されていません」というメッセージが表示されます。私が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];
}
}
は、コード内の接続文字列を与えて試してみて、それが正しいのです – Eldho