private void okButton_Click(object sender, EventArgs e) { DataContext = new FudgeDataContext(String.Format("Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3}", serverComboBox.Text, databaseComboBox.Text, userTextBox.Text, passwordTextBox.Text)); if (!DataContext.DatabaseExists()) { MessageBox.Show("An error occured while establishing the connection", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (rememberCheckBox.Checked) { Settings.Default.SavedUser = userTextBox.Text; Settings.Default.SavedPassword = passwordTextBox.Text; Settings.Default.SavedCheckBox = true; } else { Settings.Default.SavedUser = String.Empty; Settings.Default.SavedPassword = String.Empty; Settings.Default.SavedCheckBox = false; } Settings.Default.Save(); DialogResult = DialogResult.OK; }