Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Obtain the number of columns in a flatfile connection manager

$
0
0

I have an issue with importing a CSV file, whereby processing continues even if the number of input columns is incorrect. So my basic question is, how can I do that? At the moment, all that happens is the target table in the database ends up with no values but that could be a valid result so long as the number of columns is valid.

For example:

A,B,C,D,E{LF} -- valid
A,B,C,D,{LF} -- valid

A,B,C,D{LF} -- invalid

My thinking was to write a script task which reads the first line of the input file, counts the columns, compares with the number against those in the connection manager (I want the script to be dynamic) and if they don't match, throw an error. I've managed to get as far as:

DtsProperty d = Dts.Connections["flatfile"].Properties["Columns"];

but I can't work out how to get the details of the "d" object. I can see from the properties pane that it's a "System.__ComObject" but can't work out how to explore/iterate it.

So, is it possible to get the columns count from a flatfile connection manager and if so how?

If not, how can I verify that my input file has the right number of columns and, if it doesn't, error?

Thanks.


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>