Wednesday, March 21, 2012

How to connect ExecuteSQLTask with data flow task

Hi, there;
I am doing my first SSIS project that moves data from dbf file to SQL2005.
What I did here is that I created a dataflow task (move data)with ASP.NET successfully (Very happy!). Now I want to create an ExecuteSQLTask that runs before data flow runs. This ExecuteSQLTask is used used to create a table if there is no destination table in the SQL2005.
This can be done easily in SSIS design mode, just need to connect those two box with a green line: )
I had a look example from MS website, but I didn't find a code example to connect this two task.
Does anybody know how to resolve this or have any link with sample code?

Big thanks here.

Not sure what the issue is. Just drag the green line to the data flow task.|||

I am creating SSIS package from C# manully, not using the SQL Server Business Intelligence Development Studio at all. So I'd like to know how to connect these two task using C# code.

Thanks.

|||

Try this:

.....

//Create the package
Package pkg = new Package();

//Add the tasks
TaskHost sqlTask = (TaskHost)pkg.Executables.Add("STOCK:SQLTask");
TaskHost pipelinetask = (TaskHost)pkg.Executables.Add("STOCK:PipelineTask");

//Add the PrecedenceConstraint
PrecedenceConstraint pc = pkg.PrecedenceConstraints.Add(sqltask, pipelinetask);
pc.Value = DTSExecResult.Success;

.....

HTH,
Ovidiu Burlacu

No comments:

Post a Comment