方法已找到:如下
1. 在vs2005【解决方案管理器】中双击【properties】;
2. 选择【设置】tab page, 单击【查看代码】;
3. 在 Settings 类 的构造函数中增加如下代码: this.SettingsLoaded += new System.Configuration.SettingsLoadedEventHandler(Settings_SettingsLoaded); 4. 然后在添加如下事件: private void Settings_SettingsLoaded(object sender, System.Configuration.SettingsLoadedEventArgs e)
{
string connectionString = Settings.Default.anjouConnectionString;
//修改连接字符串中的【数据库文件路径】
connectionString = connectionString.Replace(@"\App_Data\db1.mdb",
System.Web.HttpContext.Current.Request.PhysicalApplicationPath+ @"\App_Data\db1.mdb");
//修改连接字符串中的【密码】
connectionString = connectionString.Replace("Database Password=123", "Database Password=newpassword");
this["anjouConnectionString"] = connectionString;