静的な Global.cs で接続文字列を使用していますが、実行時にデータベース接続を変更したいと考えています。そのため、データベース名をiniファイルに保存し、実行時に変更しています。接続文字列を、更新した次のデータベースに向けたいと思います。そのデータベース名をiniファイルから取得できます。
接続文字列 db1 を db2 に変更しようとしました。実行時にその接続文字列を別のデータベースに変更する方法を教えてください...
iam using Connection string in static Global.cs file that is
static Global()
{
try
{
ConnectionStringSettingsCollection getConFromAPP = ConfigurationManager.ConnectionStrings;
string con = getConFromAPP["DatabseConnection"].ConnectionString;
conStrYearDatabase = new SqlConnection(con);
conStrYearDatabase.Open();
}
catch (Exception e1)
{
Console.Write(e1.Message);
}
}
実行時に同じ静的クラス ファイルを 2 回目に実行する方法