Program aracılığıyla giriş sütunları seçme

Program bileşenlerini bağlandıktan sonra sen dönüştürmek veya geçmek için aşağı akım bileşenleri ters yönde bileşenlerinden sütunları seçin. Bileşen için giriş sütunları seçmezseniz, bileşen satırları veri akışı görev almaz.

Sütunları seçme

Arama GetVirtualInputsonra bir ters yönde bileşenden kullanılabilir sütunların listesini almak için yöntemini çağırın SetUsageTypeyöntemi sanal giriş sütun koleksiyonundan sütunları seçmek için tasarım zamanı bileşeni örneği. Bu yöntemi çağırın, bileşen ters yönde bileşen çıkış topluluğu aynı karşılık gelen sütun lineage kimliği olan, giriş sütun koleksiyonunda yeni bir giriş sütun oluşturur.

Sütunları çağırarak seçmeyin SetUsageTypesanal giriş yöntemi nesneyi doğrudan, çünkü bu bileşenin uygunsuz veri türleri veya diğer özelliklerini temel alan sütunlar reddetme yeteneği atlar.

Örnek

Aşağıdaki kod örneği, bir bileşen için sütunları seçmek için bir bileşen Tasarım Zamanı örneğini kullanın gösterilmiştir.

using System;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace Microsoft.SqlServer.Dts.Samples
{
  class Program
  {
    static void Main(string[] args)
    {
      // Create a package and add a Data Flow task.
      Package package = new Package();
      Executable e = package.Executables.Add("STOCK:PipelineTask");
      TaskHost thMainPipe = e as TaskHost;
      MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

      // Add an OLE DB connection manager to the package.
      ConnectionManager conMgr = package.Connections.Add("OLEDB");
      conMgr.ConnectionString = "Provider=SQLOLEDB.1;" +
        "Data Source=<servername>;Initial Catalog=AdventureWorks;" +
        "Integrated Security=SSPI;";
      conMgr.Name = "SSIS Connection Manager for OLE DB";
      conMgr.Description = "OLE DB connection to the AdventureWorks database.";

      // Create and configure an OLE DB source component.  
      IDTSComponentMetaData100 source =
        dataFlowTask.ComponentMetaDataCollection.New();
      source.ComponentClassID = "DTSAdapter.OleDbSource";
      // Create the design-time instance of the source.
      CManagedComponentWrapper srcDesignTime = source.Instantiate();
      // The ProvideComponentProperties method creates a default output.
      srcDesignTime.ProvideComponentProperties();
      // Assign the connection manager.
      source.RuntimeConnectionCollection[0].ConnectionManager =
        DtsConvert.GetExtendedInterface(conMgr);
      // Set the custom properties of the source.
      srcDesignTime.SetComponentProperty("AccessMode", 2);
      srcDesignTime.SetComponentProperty("SqlCommand",
        "Select * from Production.Product");

      // Connect to the data source,
      //  and then update the metadata for the source.
      srcDesignTime.AcquireConnections(null);
      srcDesignTime.ReinitializeMetaData();
      srcDesignTime.ReleaseConnections();

      // Create and configure an OLE DB destination.
      IDTSComponentMetaData100 destination =
        dataFlowTask.ComponentMetaDataCollection.New();
      destination.ComponentClassID = "DTSAdapter.OleDbDestination";
      // Create the design-time instance of the destination.
      CManagedComponentWrapper destDesignTime = destination.Instantiate();
      // The ProvideComponentProperties method creates a default input.
      destDesignTime.ProvideComponentProperties();

      // Create the path from source to destination.
      IDTSPath100 path = dataFlowTask.PathCollection.New();
      path.AttachPathAndPropagateNotifications(source.OutputCollection[0],
        destination.InputCollection[0]);

      // Get the destination's default input and virtual input.
      IDTSInput100 input = destination.InputCollection[0];
      IDTSVirtualInput100 vInput = input.GetVirtualInput();

      // Iterate through the virtual input column collection.
      foreach (IDTSVirtualInputColumn100 vColumn in vInput.VirtualInputColumnCollection)
      {
        // Call the SetUsageType method of the destination
        //  to add each available virtual input column as an input column.
        destDesignTime.SetUsageType(
           input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READONLY);
      }

      // Verify that the columns have been added to the input.
      foreach (IDTSInputColumn100 inputColumn in destination.InputCollection[0].InputColumnCollection)
        Console.WriteLine(inputColumn.Name);
      Console.Read();

      // Add other components to the data flow and connect them.
    }
  }
}
using System;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;

namespace Microsoft.SqlServer.Dts.Samples
{
  class Program
  {
    static void Main(string[] args)
    {
      // Create a package and add a Data Flow task.
      Package package = new Package();
      Executable e = package.Executables.Add("STOCK:PipelineTask");
      TaskHost thMainPipe = e as TaskHost;
      MainPipe dataFlowTask = thMainPipe.InnerObject as MainPipe;

      // Add an OLE DB connection manager to the package.
      ConnectionManager conMgr = package.Connections.Add("OLEDB");
      conMgr.ConnectionString = "Provider=SQLOLEDB.1;" +
        "Data Source=<servername>;Initial Catalog=AdventureWorks;" +
        "Integrated Security=SSPI;";
      conMgr.Name = "SSIS Connection Manager for OLE DB";
      conMgr.Description = "OLE DB connection to the AdventureWorks database.";

      // Create and configure an OLE DB source component.  
      IDTSComponentMetaData100 source =
        dataFlowTask.ComponentMetaDataCollection.New();
      source.ComponentClassID = "DTSAdapter.OleDbSource";
      // Create the design-time instance of the source.
      CManagedComponentWrapper srcDesignTime = source.Instantiate();
      // The ProvideComponentProperties method creates a default output.
      srcDesignTime.ProvideComponentProperties();
      // Assign the connection manager.
      source.RuntimeConnectionCollection[0].ConnectionManager =
        DtsConvert.GetExtendedInterface(conMgr);
      // Set the custom properties of the source.
      srcDesignTime.SetComponentProperty("AccessMode", 2);
      srcDesignTime.SetComponentProperty("SqlCommand",
        "Select * from Production.Product");

      // Connect to the data source,
      //  and then update the metadata for the source.
      srcDesignTime.AcquireConnections(null);
      srcDesignTime.ReinitializeMetaData();
      srcDesignTime.ReleaseConnections();

      // Create and configure an OLE DB destination.
      IDTSComponentMetaData100 destination =
        dataFlowTask.ComponentMetaDataCollection.New();
      destination.ComponentClassID = "DTSAdapter.OleDbDestination";
      // Create the design-time instance of the destination.
      CManagedComponentWrapper destDesignTime = destination.Instantiate();
      // The ProvideComponentProperties method creates a default input.
      destDesignTime.ProvideComponentProperties();

      // Create the path from source to destination.
      IDTSPath100 path = dataFlowTask.PathCollection.New();
      path.AttachPathAndPropagateNotifications(source.OutputCollection[0],
        destination.InputCollection[0]);

      // Get the destination's default input and virtual input.
      IDTSInput100 input = destination.InputCollection[0];
      IDTSVirtualInput100 vInput = input.GetVirtualInput();

      // Iterate through the virtual input column collection.
      foreach (IDTSVirtualInputColumn100 vColumn in vInput.VirtualInputColumnCollection)
      {
        // Call the SetUsageType method of the destination
        //  to add each available virtual input column as an input column.
        destDesignTime.SetUsageType(
           input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READONLY);
      }

      // Verify that the columns have been added to the input.
      foreach (IDTSInputColumn100 inputColumn in destination.InputCollection[0].InputColumnCollection)
        Console.WriteLine(inputColumn.Name);
      Console.Read();

      // Add other components to the data flow and connect them.
    }
  }
}
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Module Module1

  Sub Main()

    ' Create a package and add a Data Flow task.
    Dim package As Microsoft.SqlServer.Dts.Runtime.Package = _
      New Microsoft.SqlServer.Dts.Runtime.Package()
    Dim e As Executable = package.Executables.Add("STOCK:PipelineTask")
    Dim thMainPipe As Microsoft.SqlServer.Dts.Runtime.TaskHost = _
      CType(e, Microsoft.SqlServer.Dts.Runtime.TaskHost)
    Dim dataFlowTask As MainPipe = CType(thMainPipe.InnerObject, MainPipe)

    ' Add an OLE DB connection manager to the package.
    Dim conMgr As ConnectionManager = package.Connections.Add("OLEDB")
    conMgr.ConnectionString = "Provider=SQLOLEDB.1;" & _
      "Data Source=<servername>;Initial Catalog=AdventureWorks;" & _
      "Integrated Security=SSPI;"
    conMgr.Name = "SSIS Connection Manager for OLE DB"
    conMgr.Description = "OLE DB connection to the AdventureWorks database."

    ' Create and configure an OLE DB source component.  
    Dim source As IDTSComponentMetaData100 = _
      dataFlowTask.ComponentMetaDataCollection.New
    source.ComponentClassID = "DTSAdapter.OleDbSource"
    ' Create the design-time instance of the source.
    Dim srcDesignTime As CManagedComponentWrapper = source.Instantiate
    ' The ProvideComponentProperties method creates a default output.
    srcDesignTime.ProvideComponentProperties()
    ' Assign the connection manager.
    source.RuntimeConnectionCollection(0).ConnectionManager = _
      DtsConvert.GetExtendedInterface(conMgr)
    ' Set the custom properties of the source.
    srcDesignTime.SetComponentProperty("AccessMode", 2)
    srcDesignTime.SetComponentProperty("SqlCommand", _
      "Select * from Production.Product")

    ' Connect to the data source,
    '  and then update the metadata for the source.
    srcDesignTime.AcquireConnections(Nothing)
    srcDesignTime.ReinitializeMetaData()
    srcDesignTime.ReleaseConnections()

    ' Create and configure an OLE DB destination.
    Dim destination As IDTSComponentMetaData100 = _
      dataFlowTask.ComponentMetaDataCollection.New
    destination.ComponentClassID = "DTSAdapter.OleDbDestination"
    ' Create the design-time instance of the destination.
    Dim destDesignTime As CManagedComponentWrapper = destination.Instantiate
    ' The ProvideComponentProperties method creates a default input.
    destDesignTime.ProvideComponentProperties()

    ' Create the path from source to destination.
    Dim path As IDTSPath100 = dataFlowTask.PathCollection.New
    path.AttachPathAndPropagateNotifications(source.OutputCollection(0), _
      destination.InputCollection(0))

    ' Get the destination's default input and virtual input.
    Dim input As IDTSInput100 = destination.InputCollection(0)
    Dim vInput As IDTSVirtualInput100 = input.GetVirtualInput

    ' Iterate through the virtual input column collection.
    For Each vColumn As IDTSVirtualInputColumn100 In vInput.VirtualInputColumnCollection
      ' Call the SetUsageType method of the destination
      '  to add each available virtual input column as an input column.
      destDesignTime.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READONLY)
    Next

    ' Verify that the columns have been added to the input.
    For Each inputColumn As IDTSInputColumn100 In destination.InputCollection(0).InputColumnCollection
      Console.WriteLine(inputColumn.Name)
    Next
    Console.Read()

    ' Add other components to the data flow and connect them.

  End Sub

End Module
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Pipeline
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Module Module1

  Sub Main()

    ' Create a package and add a Data Flow task.
    Dim package As Microsoft.SqlServer.Dts.Runtime.Package = _
      New Microsoft.SqlServer.Dts.Runtime.Package()
    Dim e As Executable = package.Executables.Add("STOCK:PipelineTask")
    Dim thMainPipe As Microsoft.SqlServer.Dts.Runtime.TaskHost = _
      CType(e, Microsoft.SqlServer.Dts.Runtime.TaskHost)
    Dim dataFlowTask As MainPipe = CType(thMainPipe.InnerObject, MainPipe)

    ' Add an OLE DB connection manager to the package.
    Dim conMgr As ConnectionManager = package.Connections.Add("OLEDB")
    conMgr.ConnectionString = "Provider=SQLOLEDB.1;" & _
      "Data Source=<servername>;Initial Catalog=AdventureWorks;" & _
      "Integrated Security=SSPI;"
    conMgr.Name = "SSIS Connection Manager for OLE DB"
    conMgr.Description = "OLE DB connection to the AdventureWorks database."

    ' Create and configure an OLE DB source component.  
    Dim source As IDTSComponentMetaData100 = _
      dataFlowTask.ComponentMetaDataCollection.New
    source.ComponentClassID = "DTSAdapter.OleDbSource"
    ' Create the design-time instance of the source.
    Dim srcDesignTime As CManagedComponentWrapper = source.Instantiate
    ' The ProvideComponentProperties method creates a default output.
    srcDesignTime.ProvideComponentProperties()
    ' Assign the connection manager.
    source.RuntimeConnectionCollection(0).ConnectionManager = _
      DtsConvert.GetExtendedInterface(conMgr)
    ' Set the custom properties of the source.
    srcDesignTime.SetComponentProperty("AccessMode", 2)
    srcDesignTime.SetComponentProperty("SqlCommand", _
      "Select * from Production.Product")

    ' Connect to the data source,
    '  and then update the metadata for the source.
    srcDesignTime.AcquireConnections(Nothing)
    srcDesignTime.ReinitializeMetaData()
    srcDesignTime.ReleaseConnections()

    ' Create and configure an OLE DB destination.
    Dim destination As IDTSComponentMetaData100 = _
      dataFlowTask.ComponentMetaDataCollection.New
    destination.ComponentClassID = "DTSAdapter.OleDbDestination"
    ' Create the design-time instance of the destination.
    Dim destDesignTime As CManagedComponentWrapper = destination.Instantiate
    ' The ProvideComponentProperties method creates a default input.
    destDesignTime.ProvideComponentProperties()

    ' Create the path from source to destination.
    Dim path As IDTSPath100 = dataFlowTask.PathCollection.New
    path.AttachPathAndPropagateNotifications(source.OutputCollection(0), _
      destination.InputCollection(0))

    ' Get the destination's default input and virtual input.
    Dim input As IDTSInput100 = destination.InputCollection(0)
    Dim vInput As IDTSVirtualInput100 = input.GetVirtualInput

    ' Iterate through the virtual input column collection.
    For Each vColumn As IDTSVirtualInputColumn100 In vInput.VirtualInputColumnCollection
      ' Call the SetUsageType method of the destination
      '  to add each available virtual input column as an input column.
      destDesignTime.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READONLY)
    Next

    ' Verify that the columns have been added to the input.
    For Each inputColumn As IDTSInputColumn100 In destination.InputCollection(0).InputColumnCollection
      Console.WriteLine(inputColumn.Name)
    Next
    Console.Read()

    ' Add other components to the data flow and connect them.

  End Sub

End Module
Integration Services simgesi (küçük) Integration Services ile güncel kalın

En son karşıdan yüklemeler, makaleler, örnekler ve Microsoft video yanı sıra topluluk seçili çözümleri için ziyaret Integration ServicesMSDN sayfası:


Bu güncelleştirmelerle ilgili otomatik bildirim almak için, sayfadaki RSS akışlarına abone olun.

Ayrıca bkz.

Kavramlar

Bir paketin programsal olarak kaydetme