private void button1_Click(object sender, EventArgs e) { string str = this.GetConnectionString(); if (!string.IsNullOrEmpty(str)) { SqlConnection db = new SqlConnection(str + DbConnectionManager.TimeoutString); try { db.Open(); db.Close(); DbConnectionManager.SetResult((DbConnection)this.ParentForm, true, str); this.ParentForm.Close(); } catch (SqlException ex) { DbConnectionManager.SetResult((DbConnection)this.ParentForm, false, str); MsgBox.Alert("连接失败,错误信息:" + ex.Message); } finally { if (db != null) { db.Close(); } } } }
private void btnMySqlConnection_Click(object sender, EventArgs e) { string str = this.GetMySqlConnectionString(true); if (!string.IsNullOrEmpty(str)) { Result result = DataBaseHelper.Test(DataBaseType.MySql, new DbConnectionOptions() { ConnectionString = str }); if (!result.IsSuccess) { DbConnectionManager.SetResult((DbConnection)this.ParentForm, false, string.Empty); MsgBox.Alert(result.Msg); } else { DbConnectionManager.SetResult((DbConnection)this.ParentForm, true, str); this.ParentForm.Close(); } } }
private void button2_Click(object sender, EventArgs e) { DbConnectionManager.SetResult((DbConnection)this.ParentForm, false, string.Empty); this.ParentForm.Close(); }
private void btnMySqlCancel_Click(object sender, EventArgs e) { DbConnectionManager.SetResult((DbConnection)this.ParentForm, true, string.Empty); this.ParentForm.Close(); }