protected ColumnStrategy() { _dataAccessProvider = new DataAccessProviderFactory(Server.ProviderType); _connection = _dataAccessProvider.CreateConnection(Server.ConnectionString); _columns = new ColumnCollection(); _keys = new KeyCollection(); }
protected internal TableCollection GetTables(Database database) { TableCollection tables = new TableCollection(); DataAccessProviderFactory dataAccessProviderFactory = new DataAccessProviderFactory(Server.ProviderType); IDbConnection connection = dataAccessProviderFactory.CreateConnection(Server.ConnectionString); if(connection.State == ConnectionState.Closed) { connection.Open(); } connection.ChangeDatabase(database.Name); DataSet ds; if (Server.ProviderType != DataProviderType.Oracle) { connection.ChangeDatabase(database.Name); ds = TableSchema(dataAccessProviderFactory, connection); } else { ds = TableSchema(dataAccessProviderFactory, connection, database); } connection.Close(); /* Changed by Ferhat */ if (ds.Tables.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { tables.Add(CreateTable(database, row)); } } return tables; }
protected internal DatabaseCollection GetDatabases() { DatabaseCollection databases = new DatabaseCollection(); DataAccessProviderFactory dataAccessProviderFactory = new DataAccessProviderFactory(Server.ProviderType); IDbConnection connection = dataAccessProviderFactory.CreateConnection(Server.ConnectionString); DataSet ds = DatabaseSchema(dataAccessProviderFactory, connection); foreach (DataRow row in ds.Tables[0].Rows) { databases.Add(CreateDatabase(row, databases)); } return databases; }
/* Add by Ferhat */ protected internal TableCollection GetViews(Database database) { var tables = new TableCollection(); var dataAccessProviderFactory = new DataAccessProviderFactory(Server.ProviderType); var connection = dataAccessProviderFactory.CreateConnection(Server.ConnectionString); if (connection.State == ConnectionState.Closed) { connection.Open(); } connection.ChangeDatabase(database.Name); var ds = ViewSchema(dataAccessProviderFactory, connection); connection.Close(); if (ds.Tables.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { tables.Add(CreateTable(database, row)); } } return tables; }
private void uiTestConnectionButton_Click(object sender, EventArgs e) { if (uiProviderTypeSelection.SelectedIndex >= 0) { DataAccessProviderFactory dataAccessProvider = new DataAccessProviderFactory(((DataAccessProviderInfo) uiProviderTypeSelection.SelectedItem).ProviderType); IDbConnection connection = dataAccessProvider.CreateConnection(uiConnectionStringComboList.Text.Trim()); try { connection.Open(); MessageBox.Show("Connection Succesfull"); } catch (Exception e1) { MessageBox.Show(e1.Message); } finally { if (connection.State != ConnectionState.Closed) { connection.Close(); } } } }