Пример #1
0
        // Factory method
        internal static DataSourceOleDb Create(string locator)
        {
            var ds = new DataSourceOleDb {
                _connector = locator,
            };

            try {
                ds._connection = new OleDbConnection(locator);
            } catch (Exception ex) {
                throw Error.Fatal($"Source OleDb: {ex.Message}");
            }
            ds._convdict = new Dictionary <string, CommonType> {
                { "DBTYPE_BOOL", CommonType.Bool },
                { "DBTYPE_I4", CommonType.Integer },
                { "DBTYPE_DATE", CommonType.Time },
                { "DBTYPE_WVARCHAR", CommonType.Text },
                { "DBTYPE_WVARLONGCHAR", CommonType.Text },
            };
            return(ds);
        }
Пример #2
0
        // 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}");
            }
        }