public override DatabaseSchema BuildDatabaseSchema(string connectionString, Adapdev.Data.DbType databaseType, Adapdev.Data.DbProviderType providerType, string schemaFilter)
		{
			DataTable schemaTables = this.GetOleDbSchema(_callback, connectionString, OleDbSchemaGuid.Tables, "",schemaFilter,"","");
			DatabaseSchema di = new DatabaseSchema();
			if (schemaTables != null) 
			{ 
				if (schemaTables.Rows.Count > 0) 
				{
					//TODO: Note sure if this is valid. It does not work for Oracle DB's
					di.Name = schemaTables.Rows[0]["TABLE_CATALOG"].ToString();
					if (di.Name == String.Empty) di.Name = "Unknown";
			
					// Build the base schema information
					if (!StartProgress(_callback, "Building Table Details",schemaTables.Rows.Count,ref recordCount)) return null;
					foreach (DataRow dr in schemaTables.Rows) 
					{
						TableType tableType = TableTypeConverter.Convert(dr["TABLE_TYPE"].ToString());
						if (tableType == TableType.TABLE || tableType == TableType.VIEW) 
						{
							if (!IncrProgress(_callback, dr["TABLE_NAME"].ToString(), ref recordCount)) return null;

							TableSchema ti = CreateTableSchema(dr);
							CreateColumnSchemas(ti, connectionString, databaseType);

							if(ti.Columns.Count > 0) di.AddTable(ti);
						}
					}

					// Get the primary key information
					DataTable pkeys = this.GetOleDbSchema(_callback, connectionString, OleDbSchemaGuid.Primary_Keys, "",schemaFilter,"","");
					if (pkeys != null) 
					{
						if (!StartProgress(_callback, "Building Primary Key Details",pkeys.Rows.Count,ref recordCount)) return null;
						foreach (DataRow dr in pkeys.Rows) 
						{
							string pkTable = dr["TABLE_NAME"].ToString();
							if (!IncrProgress(_callback, dr["TABLE_NAME"].ToString(), ref recordCount)) return null;

							TableSchema tip = di[pkTable];
							if (tip != null) 
							{
								ColumnSchema ci = tip[dr["COLUMN_NAME"].ToString()];
								if (ci != null) 
								{
									ci.IsPrimaryKey = true;
									tip.AddColumn(ci);
								}
							}
						}
					}
				
					// Get the foreign key information
					DataTable fkeys = this.GetOleDbSchema(_callback, connectionString, OleDbSchemaGuid.Foreign_Keys, "",schemaFilter,"","");
					if (fkeys != null) 
					{
						if (!StartProgress(_callback, "Building Foreign Key Details",fkeys.Rows.Count,ref recordCount)) return null;
						foreach (DataRow dr in fkeys.Rows) 
						{
							string fkTable = dr["FK_TABLE_NAME"].ToString();
							if (!IncrProgress(_callback, dr["FK_TABLE_NAME"].ToString(), ref recordCount)) return null;

							TableSchema tif = di[fkTable];
							if (tif != null) 
							{
								ColumnSchema ci = tif[dr["FK_COLUMN_NAME"].ToString()];
								if (ci != null) 
								{
									ci.IsForeignKey = true;
									tif.AddColumn(ci);
								}
							}
						}
					}

					// Setup the Progress Display if one is defined. 
					if (fkeys != null) 
					{
						if (!StartProgress(_callback, "Building Foreign Key Relationships",fkeys.Rows.Count,ref recordCount)) return null;
						foreach (DataRow dr in fkeys.Rows) 
						{
							if (!IncrProgress(_callback, dr["PK_TABLE_NAME"].ToString(), ref recordCount)) return null;

							// Get the name of the primary key table
							string pkTable = dr["PK_TABLE_NAME"].ToString();
							// Get the name of the foreign key table
							string fkTable = dr["FK_TABLE_NAME"].ToString();
							// Get the name of the foreign key column
							string fkColumn = dr["FK_COLUMN_NAME"].ToString();

							// Get the table containing the primary key
							TableSchema tif = di[pkTable];
							// Get the table containing the foreign key
							TableSchema fk = di[fkTable];
							if (tif != null) 
							{
								// Get the primary key
								ColumnSchema ci = tif[dr["PK_COLUMN_NAME"].ToString()];
								// Get the foreign key
								ColumnSchema cf = fk[fkColumn];
								if (ci != null) 
								{
									// Add the association to the table and column containing the foreign key
									ci.ForeignKeyTables.Add(new ForeignKeyAssociation(ci, cf ,fk));
								}
							}
						}
					}
					if (!EndProgress(_callback, "Finished Loading Tables",true)) return null;
				} 
				else 
				{
					if (!EndProgress(_callback, "No database schema information found.",false)) return null;
				} 
			} 
			else 
			{
				if (!EndProgress(_callback, "No database schema information found.",false)) return null;
			}
			return di;
		}
		public void RefreshDBInfo(DataSource dataSource, DatabaseSchema database, TableSchema table) {
			DataSourceName = dataSource.Name;
			DBName = database.Name;
			DBEntityName = table.Name;
			if (Name == string.Empty) {
				Name = table.Name.Replace(" ", "");
			}
			FillFields(table);
			FillIndexes(dataSource);
		}
		public override DataSourceEntityGroup[] ListEntities()
		{
			_dbschema = SchemaBuilder.CreateDatabaseSchema(this.ConnectionString, DbType.SQLSERVER, DbProviderType.OLEDB);
			DataSourceEntityGroup tables = new DataSourceEntityGroup("Tables");
			DataSourceEntityGroup views = new DataSourceEntityGroup("Views");
			foreach (TableSchema entity in _dbschema.SortedTables.Values) 
			{
				if (entity.TableType == TableType.TABLE) 
				{
					tables.AddEntity(entity.Name);
				}
				else if (entity.TableType == TableType.VIEW) 
				{
					views.AddEntity(entity.Name);
				}
			}
			return new DataSourceEntityGroup[] {tables, views};
		}