// Create an input source of given type and location // The locator argument is a path or connection string. The actual filename or table name comes later. public static DataSourceStream Create(string source, string locator) { switch (source) { case "con": return(DataSourceCon.Create(locator)); case "txt": return(DataSourceFile.Create(locator)); case "csv": return(DataSourceCsv.Create(locator)); case "sql": return(DataSourceSql.Create(locator)); case "oledb": return(DataSourceOleDb.Create(locator)); case "odbc": return(DataSourceOdbc.Create(locator)); default: Logger.Assert(false, source); break; } return(null); }
// Factory method public static DataSourceOleDb Create(string locator) { var ds = new DataSourceOleDb { _locator = locator, }; try { ds._connection = new OleDbConnection(locator); } catch (Exception ex) { throw ProgramError.Fatal("Source OleDb", ex.Message); } ds._convdict = new Dictionary <string, ConversionTypes> { { "DBTYPE_BOOL", ConversionTypes.Bool }, { "DBTYPE_I4", ConversionTypes.Int }, { "DBTYPE_DATE", ConversionTypes.DateTime }, { "DBTYPE_WVARCHAR", ConversionTypes.String }, { "DBTYPE_WVARLONGCHAR", ConversionTypes.String }, }; ds._schemadict = new Dictionary <string, ConversionTypes> { { "_TABLE", ConversionTypes.Bool }, }; return(ds); }