private void connectButton_Click(object sender, EventArgs e) { string datasource = serverBox.Text; string database = dbNameBox.Text; string username = usernameBox.Text ?? ""; string userpass = userpassBox.Text ?? ""; if (string.IsNullOrEmpty(datasource) || string.IsNullOrEmpty(database)) { MessageBox.Show("Connection error! Some required fields not filled.", "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (DBConnectionService.SetSqlConnection(GetDBConnectionString(datasource, database, username, userpass))) { MessageBox.Show("Passed!", "Connection passed", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }
private void button3_Click_1(object sender, EventArgs e) { string datasource = textBox1.Text; string database = textBox2.Text; string username = textBox3.Text ?? ""; string userpass = textBox4.Text ?? ""; if (string.IsNullOrEmpty(datasource) || string.IsNullOrEmpty(database)) { MessageBox.Show("Ошибка! Не все поля заполнены.", "Ошибка соединения", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (DBConnectionService.SetSqlConnection(GetDBConnectionString(datasource, database, username, userpass))) { MessageBox.Show("Выполнено!", "Соединение подключено", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); new Form3().Show(); } }