Write to text file in SSIS using .Net

We use Data Flow Task in  SSIS package to write the info from the table Customers into text file 'OutputReport.txt'.

The table Customers gets new columns/new info every 3-4 weeks so I have to re-create/update Flat File Connection Manager at the same time..to include new colums into output text  file 'OutputReport.txt'.

I need to modify this SSIS  so SSIS will dynamically read all existing fields from table Customers and write into text file 'OutputReport.txt'. I'm trying to use .Net code inside of Script Task similar to what's shown at
http://www.aspsnippets.com/Articles/Export-data-from-SQL-Server-to-Text-file-in-C-and-VBNet.aspx

My Question:
How can I read in the code the width of each column (for example: for column Zip the width=5, for column City  the width=50 -please see the screenshot )??

In other words, .Net logic (inside of Script task) should read the Definition for each column from table Customers and format output data correctly..similar to how it's formatted in Flat File Connection Manager in SSIS.

I have attached SSIS package (Please  rename  Package.txt to Package.dtsx).

----Zip.jpg
City.jpg-----
Table Customers Structure:

CREATE TABLE [dbo].[Customers](
      [CustID] [int] IDENTITY(1,1) NOT NULL,
      [FirstName] [varchar](50) NOT NULL,
      [LastName] [varchar](50) NOT NULL,
      [Address] [varchar](50) NULL,
      [City] [varchar](50) NULL,
      [State] [varchar](2) NULL,
      [Zip] [varchar](5) NULL,
      [OrdersQ] [int] NULL
)
------------------------------------------------------
Thanks
Package.txt
Customers.xlsx
niceguy971Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sachiekCommented:
If you are trying to use flatfile connection then it is not possible to make it dynamic formatting.

Rather you can use .net code itself to write this text file. In that why you can easily dynamically fix this length and easily write to text file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
niceguy971Author Commented:
Are there any limitations on Datatable?  Any limits on number of rows/columns/data volume??
I want to use code similar to what's shown at
http://www.aspsnippets.com/Articles/Export-data-from-SQL-Server-to-Text-file-in-C-and-VBNet.aspx

but I would like to make sure it still works when my source table becomes very big.

Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.