private bool CreateDatabase() { bool error = false; string connectString = SqlServers.BuildConnectionString(optCreationIntegratedSecurity.Checked, string.Empty, cboCreationServerName.Text, txtCreationUserName.Text, txtCreationPassword.Text); if (SqlServers.TestConnectionString(connectString) && SqlServers.HasCreatePermissions(connectString)) { try { var setup = new InstallSetup() { MasterConnectionString = connectString, NewDatabaseName = txtCreationDatabaseName.Text, }; SqlServers.CreateDatabase(setup); } catch (Exception ex) { error = true; System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Could not create database." + Environment.NewLine + ex.Message); } } else { error = true; MessageBox.Show("The account does not have permissions to create a database on this server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(error); }
private bool CreateDatabase() { var error = false; var connectString = SqlServers.BuildConnectionString(optCreationIntegratedSecurity.Checked, string.Empty, cboCreationServerName.Text, txtCreationUserName.Text, txtCreationPassword.Text); if (SqlServers.TestConnectionString(connectString) && SqlServers.HasCreatePermissions(connectString)) { if (!string.IsNullOrWhiteSpace(txtDiskPath.Text) && !Directory.Exists(txtDiskPath.Text)) { error = true; MessageBox.Show("The specified disk path does not exist.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(error); } try { var setup = new InstallSetup() { MasterConnectionString = connectString, NewDatabaseName = txtCreationDatabaseName.Text, DiskPath = txtDiskPath.Text.Trim(), }; SqlServers.CreateDatabase(setup); } catch (Exception ex) { error = true; System.Diagnostics.Debug.WriteLine(ex.ToString()); MessageBox.Show("Could not create database." + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { error = true; MessageBox.Show("The account does not have permissions to create a database on this server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(error); }