![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm Currently working on a custom pipeline component wich write specific text file so I need to convert each columns into string. We've many DataType in SSIS for DataType Enum : ____________________________________ DT_BOOLA Boolean value. .... DT_UI1A 1-byte, unsigned integer. DT_UI2A 2-byte, unsigned integer. DT_UI4A 4-byte, unsigned integer. DT_UI8An 8-byte, unsigned integer. DT_WSTRA null-terminated Unicode character string. ______________________________________ I'm thinking to write a method to convert it wich looks like :; private string getString( PipelineBuffer buffer, ColumnInformation colInfo) { string text; // string Type if (colInfo.DataType == DataType.DT_NTEXT || colInfo.DataType == DataType.DT_STR || colInfo.DataType == DataType.DT_TEXT || colInfo.DataType == DataType.DT_WSTR ) { text = buffer.GetString(colInfo.BufferIndex); } else { switch (colInfo.DataType) { case DataType.DT_BYTES: text = buffer.GetBytes(colInfo.BufferIndex).ToString(); break; case DataType.DT_CY: text = buffer.GetDecimal(colInfo.BufferIndex).ToString(); break; case DataType.DT_DATE: text = buffer.GetDateTime(colInfo.BufferIndex).ToShortDat eString(); break; } } So I see how to convert to String strings ![]() But I don't find a table giving a link beetween DT_CY (currency) to the appropriate .net type, because I will need to call the appropriate get<type of PipelineBuffer. By example, I assumed that a currency is a decimal, but I'm not sure of the way??? rgds, Renaud Harduin Paris |
#3
| |||
| |||
|
|
So you have your InputColumnCollection. You cache them along with their datatypes in a struct. I presume this will be a custom formatted text file hence what I think you are building is a Destination Adapter. We do this here http://www.amazon.com/exec/obidos/tg...glance&s=books Basically cache the InputColumnCollection At ProcessInput you iterate over the columns while Buffer.NextRow() Then add .ToString() to the value. It will look something something like if (!buffer.EndOfRowset) { while (buffer.NextRow()) { _sw.WriteLine("<START>"); for (int i = 0; i < _columnInfos.Count; i++) { ColumnInfo ci = (ColumnInfo)_columnInfos[i]; object o = buffer[ci.BufferColumnIndex]; if (o == null) { _sw.WriteLine(ci.ColumnName + ":"); } else { _sw.WriteLine(ci.ColumnName + ":" + buffer[ci.BufferColumnIndex].ToString()); } } _sw.WriteLine("<END>"); } } _sw.Close(); Allan "reno" <reno (AT) nospam (DOT) com> wrote in message news:#cYE0zi6FHA.3880 (AT) TK2MSFTNGP12 (DOT) phx.gbl: I'm Currently working on a custom pipeline component wich write specific text file so I need to convert each columns into string. We've many DataType in SSIS for DataType Enum : ____________________________________ DT_BOOLA Boolean value. .... DT_UI1A 1-byte, unsigned integer. DT_UI2A 2-byte, unsigned integer. DT_UI4A 4-byte, unsigned integer. DT_UI8An 8-byte, unsigned integer. DT_WSTRA null-terminated Unicode character string. ______________________________________ I'm thinking to write a method to convert it wich looks like :; private string getString( PipelineBuffer buffer, ColumnInformation colInfo) { string text; // string Type if (colInfo.DataType == DataType.DT_NTEXT || colInfo.DataType == DataType.DT_STR || colInfo.DataType == DataType.DT_TEXT || colInfo.DataType == DataType.DT_WSTR ) { text = buffer.GetString(colInfo.BufferIndex); } else { switch (colInfo.DataType) { case DataType.DT_BYTES: text = buffer.GetBytes(colInfo.BufferIndex).ToString(); break; case DataType.DT_CY: text = buffer.GetDecimal(colInfo.BufferIndex).ToString(); break; case DataType.DT_DATE: text = buffer.GetDateTime(colInfo.BufferIndex).ToShortDat eString(); break; } } So I see how to convert to String strings ![]() But I don't find a table giving a link beetween DT_CY (currency) to the appropriate .net type, because I will need to call the appropriate get<type of PipelineBuffer. By example, I assumed that a currency is a decimal, but I'm not sure of the way??? rgds, Renaud Harduin Paris |
![]() |
| Thread Tools | |
| Display Modes | |
| |