dbTalk Databases Forums  

SSIS Custom DataFlow Component : to SSIS data type to .net Type

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SSIS Custom DataFlow Component : to SSIS data type to .net Type in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
reno
 
Posts: n/a

Default SSIS Custom DataFlow Component : to SSIS data type to .net Type - 11-15-2005 , 03:38 PM






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



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: SSIS Custom DataFlow Component : to SSIS data type to .net Type - 11-15-2005 , 04:39 PM






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


Quote:
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


Reply With Quote
  #3  
Old   
reno
 
Posts: n/a

Default Re: SSIS Custom DataFlow Component : to SSIS data type to .net Type - 11-16-2005 , 02:13 PM



why doing simple when you can do complex !

Thk's a lot



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> a écrit dans le message de news:
%23Py9iVj6FHA.3636 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Quote:
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




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.