private bool TestConn() { DbConnect = new DBConnectModel { ServerName = txtServerName.Text, DBName = txtDBName.Text, Account = txtAccount.Text, Password = txtPassword.Text }; using (var conn = new SqlConnection(DbConnect.ConnectionString)) { try { conn.Open(); _testSuccess = true; } catch { _testSuccess = false; } } return(_testSuccess); }
public SetConnect(DBConnectModel dbConnectModel) { InitializeComponent(); if (dbConnectModel == null) { return; } DbConnect = dbConnectModel; txtServerName.Text = DbConnect.ServerName; txtDBName.Text = DbConnect.DBName; txtAccount.Text = DbConnect.Account; txtPassword.Text = DbConnect.Password; }
private void btnSetDestConn_Click(object sender, EventArgs e) { var setConnect = new SetConnect(_destDbConnectModel) { StartPosition = FormStartPosition.WindowsDefaultLocation }; var dialogResult = setConnect.ShowDialog(); if (dialogResult == DialogResult.OK) { _destDbConnectModel = setConnect.DbConnect; lblDestConnStr.Text = setConnect.DbConnect.ConnectionString; } }
private void btnCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; DbConnect = null; }