コード例 #1
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.
        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);
        }
コード例 #2
0
        public static DataSourceSql Create(string locator)
        {
            var ds = new DataSourceSql {
                _locator = locator,
            };

            try {
                ds._connection = new SqlConnection(locator);
            } catch (Exception ex) {
                throw ProgramError.Fatal("Source Sql", ex.Message);
            }
            ds._convdict = new Dictionary <string, ConversionTypes> {
                { "char", ConversionTypes.String },
                { "varchar", ConversionTypes.String },
                { "nchar", ConversionTypes.String },
                { "nvarchar", ConversionTypes.String },
                { "text", ConversionTypes.String },
                { "bit", ConversionTypes.Bool },
                { "int", ConversionTypes.Int },
                { "bigint", ConversionTypes.Int },
                { "smallint", ConversionTypes.Int },
                { "tinyint", ConversionTypes.Int },
                { "numeric", ConversionTypes.Decimal },
                { "decimal", ConversionTypes.Decimal },
                { "money", ConversionTypes.Decimal },
                { "smallmoney", ConversionTypes.Decimal },
                { "date", ConversionTypes.DateTime },
                { "datetime", ConversionTypes.DateTime },
                { "time", ConversionTypes.DateTime },
                { "datetime2", ConversionTypes.DateTime },
                { "smalldatetime", ConversionTypes.DateTime },
                { "datetimeoffset", ConversionTypes.DateTime },
            };

            return(ds);
        }