public FlatFileConnectionTypeProvider(bool isSource, String filePath, bool columnNamesinFirstRow, String columnDelimiter, String[] colNames, wrapper.DataType[] colTypes, int[] colLengths, int[] colPrecisions, int[] colScales) { ConnectionMgrName = (isSource) ? connMgrNameSource : connMgrNameDest; if (String.IsNullOrEmpty(filePath)) { throw new ArgumentException("Flat file path is empty for " + ConnectionMgrName); } if (colNames==null || colTypes==null || colLengths == null || colPrecisions==null || colScales == null) { throw new ArgumentException("One or more of the colNames, colTypes, colLengths, colPrecisions and colScales is null."); } if (colNames.Length != colTypes.Length || colTypes.Length != colLengths.Length || colLengths.Length != colPrecisions.Length || colPrecisions.Length != colScales.Length) { throw new ArgumentException("The number of elements in the colNames, colTypes, colLengths, colPrecisions and colScales are not equal"); } this.filePath = filePath; this.columnNamesinFirstRow = columnNamesinFirstRow; this.columnDelimiter = columnDelimiter; if (String.IsNullOrEmpty(columnDelimiter)) { columnDelimiter = "\t"; } this.colNames = colNames; this.colTypes = colTypes; this.colLengths = colLengths; this.colPrecisions = colPrecisions; this.colScales = colScales; }
internal CacheCols(RunWrap.IDTSConnectionManagerCacheColumns100 cols) { m_cols = cols; }
internal CacheColumn(RunWrap.IDTSConnectionManagerCacheColumn100 c) { m_col = c; }
// Add Data Conversion transform if the pair is unicode/non-unicode combination. // It can be extended to other combination. private static bool NeedConvert(wrapper.DataType srcType, wrapper.DataType destType) { if (srcType != destType) { if ((srcType == wrapper.DataType.DT_STR || srcType == wrapper.DataType.DT_TEXT) && (destType == wrapper.DataType.DT_WSTR || destType == wrapper.DataType.DT_NTEXT)) { return true; } if ((destType == wrapper.DataType.DT_STR || destType == wrapper.DataType.DT_TEXT) && (srcType == wrapper.DataType.DT_WSTR || srcType == wrapper.DataType.DT_NTEXT)) { return true; } } return false; }
private static String ConvertColumnTypeToSqlServer(wrapper.DataType dataType) { String resultString = String.Empty; switch (dataType) { case wrapper.DataType.DT_BOOL: resultString = "BIT"; break; case wrapper.DataType.DT_BYTES: resultString = "BINARY"; break; case wrapper.DataType.DT_CY: resultString = "MONEY"; break; case wrapper.DataType.DT_DATE: resultString = "DATETIME"; break; case wrapper.DataType.DT_DBDATE: resultString = "DATE"; break; case wrapper.DataType.DT_DBTIME: resultString = "TIME"; break; case wrapper.DataType.DT_DBTIME2: resultString = "TIME"; break; case wrapper.DataType.DT_DBTIMESTAMP: resultString = "DATETIME"; break; case wrapper.DataType.DT_DBTIMESTAMP2: resultString = "DATETIME2"; break; case wrapper.DataType.DT_DBTIMESTAMPOFFSET: resultString = "DATETIMEOFFSET"; break; case wrapper.DataType.DT_DECIMAL: resultString = "DECIMAL"; break; case wrapper.DataType.DT_FILETIME: resultString = "DATETIME"; break; case wrapper.DataType.DT_GUID: resultString = "UNIQUEIDENTIFIER"; break; case wrapper.DataType.DT_I1: resultString = "SMALLINT"; break; case wrapper.DataType.DT_I2: resultString = "SMALLINT"; break; case wrapper.DataType.DT_I4: resultString = "INT"; break; case wrapper.DataType.DT_I8: resultString = "BIGINT"; break; case wrapper.DataType.DT_IMAGE: resultString = "IMAGE"; break; case wrapper.DataType.DT_NTEXT: resultString = "NTEXT"; break; case wrapper.DataType.DT_WSTR: resultString = "NVARCHAR"; break; case wrapper.DataType.DT_NUMERIC: resultString = "NUMERIC"; break; case wrapper.DataType.DT_R4: resultString = "REAL"; break; case wrapper.DataType.DT_R8: resultString = "FLOAT"; break; case wrapper.DataType.DT_STR: resultString = "VARCHAR"; break; case wrapper.DataType.DT_TEXT: resultString = "TEXT"; break; case wrapper.DataType.DT_UI1: resultString = "TINYINT"; break; case wrapper.DataType.DT_UI2: resultString = "INT"; break; case wrapper.DataType.DT_UI4: resultString = "BIGINT"; break; case wrapper.DataType.DT_UI8: // SQL Server's BIGINT cannot hold UI8, so we are using NUMERIC here. resultString = "NUMERIC (20, 0)"; break; } return resultString; }