private void btnTest_Click(object sender, EventArgs e) { ConnectionInfo connectionInfo = this.GetConnectionInfo(); DbInterpreter dbInterpreter = DbInterpreterHelper.GetDbInterpreter(this.DatabaseType, connectionInfo, new GenerateScriptOption()); try { using (DbConnection dbConnection = dbInterpreter.GetDbConnector().CreateConnection()) { dbConnection.Open(); MessageBox.Show("Success."); if (string.IsNullOrEmpty(this.cboDatabase.Text.Trim())) { this.cboDatabase.Items.Clear(); List <Database> databaseses = dbInterpreter.GetDatabases(); databaseses.ForEach(item => { this.cboDatabase.Items.Add(item.Name); }); } } } catch (Exception ex) { MessageBox.Show("Failed:" + ex.Message); } }
private async void btnTest_Click(object sender, EventArgs e) { ConnectionInfo connectionInfo = this.GetConnectionInfo(); DbInterpreter dbInterpreter = DbInterpreterHelper.GetDbInterpreter(this.DatabaseType, connectionInfo, new DbInterpreterOption()); string oldDatabase = this.cboDatabase.Text; try { using (DbConnection dbConnection = dbInterpreter.GetDbConnector().CreateConnection()) { dbConnection.Open(); MessageBox.Show("Success."); this.cboDatabase.Items.Clear(); List <Database> databaseses = await dbInterpreter.GetDatabasesAsync(); databaseses.ForEach(item => { this.cboDatabase.Items.Add(item.Name); }); this.cboDatabase.Text = oldDatabase; } } catch (Exception ex) { MessageBox.Show("Failed:" + ex.Message); } }