// Factory method internal static DataSourceOdbc Create(string locator) { var ds = new DataSourceOdbc { _connector = locator, }; try { ds._connection = new OdbcConnection(locator); } catch (Exception ex) { throw Error.Fatal($"Sql: {ex.Message}"); } ds._convdict = new Dictionary <string, CommonType> { { "CHAR", CommonType.Text }, { "VARCHAR", CommonType.Text }, { "NCHAR", CommonType.Text }, { "NVARCHAR", CommonType.Text }, { "INTEGER", CommonType.Integer }, }; return(ds); }
// 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. internal static DataSourceStream Create(SourceKind source, string locator) { switch (source) { case SourceKind.Csv: return(DataSourceCsv.Create(locator)); case SourceKind.Text: return(DataSourceFile.Create(locator)); case SourceKind.Sql: return(DataSourceSql.Create(locator)); case SourceKind.Oledb: return(DataSourceOleDb.Create(locator)); case SourceKind.Odbc: return(DataSourceOdbc.Create(locator)); default: throw Error.Argument($"bad source: {source}"); } }