Yes, using code, not BIDS. We are trying to eliminate as much business logic
as possible from our SQL Server and place in .NET code. The .dtsx packages
are an option but it's my job to explore all options. BIDS is nice but
programming gives us more control.
When you add a Precedence constraint, you add a Precedence executable
(SQLTask1) and connect it to a Constrained executable (SQLTask2). It should
be as easy as pkg.Executables.Item(0) connected to pkg.Executables.Item(1).
However, if the TransferSqlServerObjectsTask is getting jammed in anywhere in
the collection, I run the risk of connection the wrong tasks together if I
loop through the exectuables in the order they are added to the package.
I have a workaround using a FOR but it shouldn't have to be done this way...
Private Sub LinkTask(ByRef p As Package, ByVal precedenceexec As
Executable, ByVal constrainedexec As Executable)
'won't enter the For loop the first time this sub is called
'because no contraints have been set yet
For Each pConstraint In p.PrecedenceConstraints
'look for the last task that is constrianed
If Not pConstraint.ConstrainedExecutable Is Nothing And
pConstraint.PrecedenceExecutable Is Nothing Then
precedenceexec = pConstraint.ConstrainedExecutable
'Now look for the transferSQLobject because it gets jammed
in the collection anywhere
For Each executable In p.Executables
If CType(executable,
TaskHost).CreationName.ToLower.IndexOf("transfersqlserver") > -1 Then
constrainedexec = executable
Exit For
End If
Next
Exit For
End If
Next
Dim pcFileTasks As PrecedenceConstraint =
p.PrecedenceConstraints.Add(precedenceexec, constrainedexec)
pcFileTasks.Value = DTSExecResult.Success
End Sub
> Help me to understand:
> You are creating this SSIS package using code, NOT the BIDS? It shouldn't
[quoted text clipped - 34 lines]
> >
> > Is this normal? What could I be doing wrong? Wish there was an AddAt method.
Todd C - 26 Jun 2009 13:41 GMT
I'm not a coding expert by any means, so take this bit of advice with a grain
of salt, and don't trust it until you have tested it yourself:
When you refer to the executable task, must it always be via the index?
Can't it be done using the name?As in:
pkg.Executables.Item("First Item")
You don't have control over the indexing of the task (it sounds like it
doesn't even honor the order in which they were added, which is a big bummer
for you) but you always have control over the name, and I thought that with
any collection that was indexed such as this, you could always refernce the
name in quotes.
Hope that helps. Like I said, I'm more of a SQL database and SSIS/BIDS guy,
not VB coding.
=====
Todd C
> Yes, using code, not BIDS. We are trying to eliminate as much business logic
> as possible from our SQL Server and place in .NET code. The .dtsx packages
[quoted text clipped - 78 lines]
> > >
> > > Is this normal? What could I be doing wrong? Wish there was an AddAt method.
KFast - 26 Jun 2009 14:50 GMT
Unfortunately it's indexed by integer only. Like I said, I have a work around
so it's no big deal anymore.
It's good that we've had this discussion in case anyone else has this
problem. Maybe they can use my work around. Thanks for your help.
> I'm not a coding expert by any means, so take this bit of advice with a grain
> of salt, and don't trust it until you have tested it yourself:
[quoted text clipped - 95 lines]
> > > >
> > > > Is this normal? What could I be doing wrong? Wish there was an AddAt method.