Re: converting data to null using DBNull problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



Have you tried

1. On the Flat File Connection Manager go to the Advanced tab have a look at the "Suggest Types" button. Hopefully this will change the default of String 50 to a proper Integer datatype

2. On the Flat File source Adapter check the box on the front screen that says "Retain null values from the source as null values in the data flow."


That should allow you to put in the right datatype and also retin nulls.

--


Regards


Allan Mitchell
Konesans Ltd
T +44 7966 476 572
F +44 2071 008 479
http://www.konesans.com



"PRW" <PRW@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:54F30B0B-3E30-46F9-BFBA-28504B5806D2@xxxxxxxxxxxxx:

I have a flat file source that in some string data rows contains all
blank
spaces.
The original data is actually numeric, so I want to convert this to
numeric
data with null values where the field exists as empty spaces.
In a ST task I can successfully do this using the DBNull function (check
by
copying the data out of Data Viewer and I believe it is now null)

Row.ST1parntiorgid = Convert.DBNull.ToString,

but, then when I move to the next task to convert the data using Data
Conversion task, from string to numeric it fails with
'.........truncation
would cause data to be lost'.
If in the ST task I convert fields with empty spaces to "0" and then
convert
to numeric it works successfully, so somehow there is an issue with
converting to null.

I tested that a DC task can convert a string datatype to numeric with
null
value in it and this works OK as expected, so I feel somehow the DBNull
function isin't actually creating a null in the fields correctly.

Any ideas anyone ?

.


Quantcast