private string BuildConnectionString(DBExecutor dbExecutor) { DBExecutor.UseDriver useDriverType; string driverName = this.GetDriverName(out useDriverType); ComboBoxDSNItem dsnItem = this.GetSelectedDSNName(); string dsn = dsnItem.IsDSN ? dsnItem.Text : string.Empty; Arguments args = new Arguments() { dbType = this.GetDatabaseTypeName(this.comboBoxDatabase.SelectedIndex), dsnName = dsn, auth_type = this.GetAuthTypeName(this.comboBoxAuthType.SelectedIndex), server = this.textBoxServerName.Text, port = this.textBoxPort.Text, database = this.textBoxDatabaseName.Text, loginName = this.textBoxLoginName.Text, loginpassword = this.textBoxLoginPassword.Text, driverName = driverName, account = this.TextBoxAccount.Text, warehouse = this.textBoxWarehouse.Text, role = this.textBoxRole.Text }; return(dbExecutor.BuildConnectionString(args, useDriverType)); }
private string BuildConnectionString(DBExecutor dbExecutor) { DBExecutor.UseDriver useDriverType; string driverName = this.GetDriverName(out useDriverType); ComboBoxDSNItem dsnItem = this.GetSelectedDSNName(); string dsn = dsnItem.IsDSN ? dsnItem.Text : string.Empty; return(dbExecutor.BuildConnectionString(this.GetDatabaseTypeName(this.comboBoxDatabase.SelectedIndex), dsn, this.GetAuthTypeName(this.comboBoxAuthType.SelectedIndex), this.textBoxServerName.Text, this.textBoxPort.Text, this.textBoxDatabaseName.Text, this.textBoxLoginName.Text, this.textBoxLoginPassword.Text, driverName, useDriverType)); }
private void InitializeDrivers(string defaultDriverName) { string sqlDialect = this.GetDatabaseTypeName(this.comboBoxDatabase.SelectedIndex); ComboBoxDSNItem dsnItem = this.GetSelectedDSNName(); this.comboBoxDriverName.Items.Clear(); if (dsnItem.IsDSN) { this.comboBoxDriverName.Enabled = false; this.textBoxDatabaseName.Enabled = false; this.textBoxPort.Enabled = false; this.textBoxServerName.Enabled = false; } else { this.comboBoxDriverName.Enabled = true; this.textBoxDatabaseName.Enabled = true; this.textBoxPort.Enabled = true; this.textBoxServerName.Enabled = true; } List <ComboBoxDriverItem> comboItems = new List <ComboBoxDriverItem>(); List <string> odbcDrivers = null; switch (sqlDialect) { case "oracle": comboItems.Add(new ComboBoxDriverItem() { Text = UIConfig.DRIVER_NAME_NATIVE, UseDriverType = DBExecutor.UseDriver.ORACLE }); odbcDrivers = ODBCUtils.GetSystemDriverList().Where(x => x.IndexOf("oracle", StringComparison.InvariantCultureIgnoreCase) >= 0).ToList(); break; case "teradata": comboItems.Add(new ComboBoxDriverItem() { Text = UIConfig.DRIVER_NAME_NATIVE, UseDriverType = DBExecutor.UseDriver.TERADATA }); odbcDrivers = ODBCUtils.GetSystemDriverList().Where(x => x.IndexOf("teradata", StringComparison.InvariantCultureIgnoreCase) >= 0).ToList(); break; case "mssql": odbcDrivers = ODBCUtils.GetSystemDriverList().Where(x => x.IndexOf("SQL", StringComparison.InvariantCultureIgnoreCase) >= 0).ToList(); break; default: odbcDrivers = new List <string>(); break; } // add ODBC drivers foreach (var item in odbcDrivers) { comboItems.Add(new ComboBoxDriverItem() { Text = item, UseDriverType = DBExecutor.UseDriver.ODBC }); } foreach (var item in comboItems) { this.comboBoxDriverName.Items.Add(item); } comboBoxDriverName.DisplayMember = "Text"; comboBoxDriverName.ValueMember = "Value"; comboBoxDriverName.SelectedIndex = -1; // preselect driver int idx = 0; foreach (ComboBoxDriverItem item in comboBoxDriverName.Items) { if (defaultDriverName == item.Text) { if (idx != comboBoxDriverName.SelectedIndex) { comboBoxDriverName.SelectedIndex = idx; } else { break; } } idx++; } if (comboBoxDriverName.SelectedIndex < 0) { comboBoxDriverName.SelectedIndex = 0; } }