Search code examples
c#sql-serverssisetlssis-2008

SSIS read flat file connection on script task


I'm working on a 2008 SSIS in which I need to read a flat file so that I can access its content (which has 3 directories paths), so I can store those 3 paths into variables.

The flat file would be in 3 different servers, according to the instance I'm working on (dev,qa,production), so I can't just write the path into a variable because I'd have to rewrite that value every time I'd need to deploy the solution in a different instance.

Something I've tried on the past is to read a flat file using the Directory.GetCurrentDirectory(), but I couldn't debug that and using the F5/run package on VS2008 didn't work (I've read that it doesn't work on VS but once you deploy the package it works fine, but I have no means to prove it but to try).

So, I figured out that, If I can read the path saved on a flat file connection and save it in a string variable, I could modify the connection string value in the .config file once the package is deployed, and read its contents like a normal flat file.

My problem is that I can't figure out how to read the connection string value, and I couldn't find anything online that pointed me in the right direction.

Thanks in advance.


Solution

  • Since nothing seemed to work, I ended up doing the following:

    • Inserted the values I needed in a parameters table in the database
    • generated an Execute SQL Task
    • assigned the results of that task to the variables

    It took me all day but I finally got it.

    I followed this thread for references.