IDTSSequence.PrecedenceConstraints IDTSSequence.PrecedenceConstraints IDTSSequence.PrecedenceConstraints Property


Returns a collection of PrecedenceConstraint objects associated with the container. This field is read-only.

 property Microsoft::SqlServer::Dts::Runtime::PrecedenceConstraints ^ PrecedenceConstraints { Microsoft::SqlServer::Dts::Runtime::PrecedenceConstraints ^ get(); };
public Microsoft.SqlServer.Dts.Runtime.PrecedenceConstraints PrecedenceConstraints { get; }
Public ReadOnly Property PrecedenceConstraints As PrecedenceConstraints

Property Value


The Package class inherits from IDTSSequence and implements an PrecedenceConstraints collection The following code sample demonstrates adding two tasks to a package. A PrecedenceConstraint is added to the PrecedenceConstraints collection. The constraint created between the tasks prevents the second task from running until the first task completes.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;  
using Microsoft.SqlServer.Dts.Tasks.FileSystemTask;  
namespace DataFlow_Conceptual  
    class Program  
        static void Main(string[] args)  
            Package p = new Package();  
            // Add a File System task.  
            Executable eFileTask1 = p.Executables.Add("STOCK:FileSystemTask");  
            TaskHost thFileHost1 = eFileTask1 as TaskHost;  
            // Add a second File System task.  
            Executable eFileTask2 = p.Executables.Add("STOCK:FileSystemTask");  
            TaskHost thFileHost2 = eFileTask2 as TaskHost;  
            // Put a precedence constraint between the tasks.  
            // Set the constraint to be that thFileTask2 cannot run  
            // until thFileTask1 completes.  
            PrecedenceConstraint pcFileTasks = p.PrecedenceConstraints.Add((Executable)thFileHost1, (Executable) thFileHost2);  
            pcFileTasks.Value = DTSExecResult.Completion;  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper  
Imports Microsoft.SqlServer.Dts.Tasks.FileSystemTask  
Namespace DataFlow_Conceptual  
    Class Program  
        Shared  Sub Main(ByVal args() As String)  
            Dim p As Package =  New Package()   
            ' Add a File System task.  
            Dim eFileTask1 As Executable =  p.Executables.Add("STOCK:FileSystemTask")   
            Dim thFileHost1 As TaskHost =  eFileTask1 as TaskHost   
            ' Add a second File System task.  
            Dim eFileTask2 As Executable =  p.Executables.Add("STOCK:FileSystemTask")   
            Dim thFileHost2 As TaskHost =  eFileTask2 as TaskHost   
            ' Put a precedence constraint between the tasks.  
            ' Set the constraint to be that thFileTask2 cannot run  
            ' until thFileTask1 completes.  
            Dim pcFileTasks As PrecedenceConstraint =  p.PrecedenceConstraints.Add(CType(thFileHost1,CType(thFileHost2, Executable, Executable)))   
            pcFileTasks.Value = DTSExecResult.Completion  
        End Sub  
    End Class  
End Namespace  


Precedence constraints establish the order that executable objects run in a package. The precedence constraint allows the control of execution of the containers and tasks in a package to be based on the result of the execution of a previous task or container. Precedence constraints are established between two Executable objects by calling the Add method of the PrecedenceConstraints collection on the container object. After creating a constraint between two executable objects, the Value property is set to establishes the criteria for executing the second executable defined in the constraint.

Applies to