DAAB without a configuration file?

Topics: Data Access Application Block
May 27, 2008 at 7:28 PM
I have the need to specify the database dynamically - i.e., not defined in a *.config file. (I'm handed a connection string by the code that consumes mine... not the NamedInstance in a config file)
I know what to do for SQL Server and Oracle... but what do I do for ODBC? (Pardon me if somehow I've overlooked a post that already answers this... just point me in the right direction.)
So for example:

 

private Database _database;
public void CreateDatabase()
{
    
switch (DatabaseType)
    {
        
case DatabaseType.SqlServer:
        case DatabaseType.SqlExpress:
            _database =
new SqlDatabase(Connection.ConnectionString);
            break;
        case DatabaseType.Oracle:
            _database =
new OracleDatabase(Connection.ConnectionString);
            break;
        case DatabaseType.Access:
            
// What goes here?
            break;
    }
}

Thanks,
Karl

 

May 27, 2008 at 7:50 PM

_database =

new GenericDatabase(Connection.ConnectionString, System.Data.OleDb.OleDbFactory.Instance);