private void GetDatabaseNamesButton_Click(object sender, EventArgs e) { if (ProviderComboBox.DataSource == null) { var dataProvider = new DatabaseProviders(); ProviderComboBox.DataSource = dataProvider.List; } if (!string.IsNullOrWhiteSpace(ServerNameTextBox.Text)) { _scaffoldBuilder.ServerName = ServerNameTextBox.Text; } var ops = new SqlServerDatabaseInformation(_scaffoldBuilder.ServerName); var result = ops.DatabaseNames(); if (ops.IsSuccessFul) { DatabaseListBox.DataSource = result; } else { MessageBox.Show($"Error: {ops.LastExceptionMessage}"); } }
/// <summary> /// Get databases from ServerName form level variable above /// </summary> private void Form1_Shown(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(_scaffoldBuilder.ServerName)) { var ops = new SqlServerDatabaseInformation(_scaffoldBuilder.ServerName); var result = ops.DatabaseNames(); if (ops.IsSuccessFul) { DatabaseListBox.DataSource = result; } else { MessageBox.Show($"Error: {ops.LastExceptionMessage}"); } } }