// 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);
 }
        public override void SetOutputColumnDataTypeProperties(int outputID, int outputColumnID, Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType dataType, int length, int precision, int scale, int codePage)

        {
            IDTSOutputCollection100 outputColl = this.ComponentMetaData.OutputCollection;

            IDTSOutput100 output = outputColl.GetObjectByID(outputID);

            IDTSOutputColumnCollection100 columnColl = output.OutputColumnCollection;

            IDTSOutputColumn100 column = columnColl.GetObjectByID(outputColumnID);

            column.SetDataTypeProperties(dataType, length, precision, scale, codePage);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the data type properties of an Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutputColumn100
        ///     object.
        /// </summary>
        /// <param name="iOutputID">The ID of the Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutput100 object.</param>
        /// <param name="iOutputColumnID">The ID of the Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSOutputColumn100 object.</param>
        /// <param name="eDataType">The Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType of the column.</param>
        /// <param name="iLength">The length of the column.</param>
        /// <param name="iPrecision">The total number of digits in the column.</param>
        /// <param name="iScale">The number of digits of precision in the column.</param>
        /// <param name="iCodePage">The code page of the column.</param>
        public override void SetOutputColumnDataTypeProperties(int iOutputID, int iOutputColumnID, Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType eDataType, int iLength, int iPrecision, int iScale, int iCodePage)
        {
            var output    = ComponentMetaData.OutputCollection.FindObjectByID(iOutputID);
            var outColumn = output.OutputColumnCollection.GetObjectByID(iOutputColumnID);

            outColumn.SetDataTypeProperties(eDataType, iLength, iPrecision, iScale, iCodePage);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Allow the user to change a String to a NText, although this may affect performance.
        /// </summary>
        /// <param name="outputID"></param>
        /// <param name="outputColumnID"></param>
        /// <param name="dataType"></param>
        /// <param name="length"></param>
        /// <param name="precision"></param>
        /// <param name="scale"></param>
        /// <param name="codePage"></param>
        public override void SetOutputColumnDataTypeProperties(int outputID, int outputColumnID, Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType dataType, int length, int precision, int scale, int codePage)
        {
            var        outputColl = this.ComponentMetaData.OutputCollection;
            IDTSOutput output     = outputColl.GetObjectByID(outputID);

            var columnColl          = output.OutputColumnCollection;
            IDTSOutputColumn column = columnColl.GetObjectByID(outputColumnID);

            var sourceColl = output.ExternalMetadataColumnCollection;
            IDTSExternalMetadataColumn columnSource = sourceColl.GetObjectByID(column.ExternalMetadataColumnID);

            if (((column.DataType == DataType.DT_WSTR) || (column.DataType == DataType.DT_NTEXT)) &&
                ((dataType == DataType.DT_NTEXT) || (dataType == DataType.DT_WSTR)))
            {
                column.SetDataTypeProperties(dataType, length, precision, scale, codePage);
            }
            else
            {
                base.SetOutputColumnDataTypeProperties(outputID, outputColumnID, dataType, length, precision, scale, codePage);
            }
        }