Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Integration Services / June 2009

Tip: Looking for answers? Try searching our database.

Package.Executables indexing problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
KFast - 24 Jun 2009 19:39 GMT
I'm trying to create a vb app that will run 2 SQLTasks and 1
TransferSQLServerObjectsTask in that exact order.

I create the first SQLTask and add it to the package...

Ex. package.Executables.Add("STOCK:SQLTask")

Then I add the second SQLTask to the package. Everything good so far.

Finally, I add the TransferSqlServerObjectsTask. I have a total of 3
Executables in the package.

p.Executables.Add("STOCK:TransferSqlServerObjectsTask")

Any reason why the TransferSqlServerObjectsTask gets placed randomly in the
executables collection?

Package.Executables.Item(2) should be the TransferSqlServerObjectsTask
because it was placed in there 3rd, right?

Actually, it's getting placed anwhere from Item(0) to (2). Maybe it doesn't
seem like a big deal but it's a real pain in the a.s when I try to link the
tasks.

Is this normal? What could I be doing wrong? Wish there was an AddAt method.
Todd C - 25 Jun 2009 14:07 GMT
Help me to understand:
You are creating this SSIS package using code, NOT the BIDS? It shouldn't
matter in what order you add the tasks, as long as you also add Precedence
Constraints between them. The Precedence Constraints will determine the order
in which the tasks execute.

Do you see anything from intelisense regarding precedence constraints when
you type "package." ?

I don't design packages this way so I may not be of much help.
=====
Todd C

> I'm trying to create a vb app that will run 2 SQLTasks and 1
> TransferSQLServerObjectsTask in that exact order.
[quoted text clipped - 21 lines]
>
> Is this normal? What could I be doing wrong? Wish there was an AddAt method.
KFast - 25 Jun 2009 18:51 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.