/// <summary> /// 事件响应 测试连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { if (TryConnection()) { /*连接成功,将新的连接串保存到配置文件*/ if (!string.IsNullOrEmpty(Config.Config.ConnectionString)) { BaseConfigInfo objBaseConfigInfo = new BaseConfigInfo(); objBaseConfigInfo.Dbconnectstring = ConnectionString; objBaseConfigInfo.Dbtype = ""; BaseConfigs.SaveConfig(objBaseConfigInfo); } else { BaseConfigInfo objBaseConfigInfo = new BaseConfigInfo(); objBaseConfigInfo.Dbconnectstring = ConnectionString; BaseConfigs.SaveConfig(objBaseConfigInfo); } MessageBox.Show("连接成功"); } }