private async void TestConnect() { ConnectionInfo connectionInfo = this.GetConnectionInfo(); DbInterpreter dbInterpreter = DbInterpreterHelper.GetDbInterpreter(this.DatabaseType, connectionInfo, new DbInterpreterOption()); string oldDatabase = this.cboDatabase.Text; try { 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); } }
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); } }
public async Task LoadTree(DatabaseType dbType, ConnectionInfo connectionInfo) { this.databaseType = dbType; this.connectionInfo = connectionInfo; this.tvDbObjects.Nodes.Clear(); DbInterpreter dbInterpreter = DbInterpreterHelper.GetDbInterpreter(dbType, connectionInfo, simpleInterpreterOption); List <Database> databases = await dbInterpreter.GetDatabasesAsync(); foreach (Database database in databases) { TreeNode node = DbObjectsTreeHelper.CreateTreeNode(database, true); this.tvDbObjects.Nodes.Add(node); } if (this.tvDbObjects.Nodes.Count == 1) { this.tvDbObjects.SelectedNode = this.tvDbObjects.Nodes[0]; this.tvDbObjects.Nodes[0].Expand(); } }