Program aracılığıyla bir paket oluşturma

The Package object is the top-level container for all other objects in an SSIS project solution.Üst düzey kapsayıcı olarak paket, oluşturulan ilk nesnedir ve sonraki nesneler kendisine eklenmiş ve sonra paketi kapsamı içinde yürütülür.Paket taşıma veya verileri dönüştürmek.Paket görevlerinde yararlanır çalışmayı gerçekleştirmek için içerir.Görevleri, paket tarafından gerçekleştirilen çalışmanın çoğunu gerçekleştirmek ve bir paketin işlevini tanımlayın.paket oluşturulur ve yalnızca üç satırlık bir kod, ancak çeşitli görevleri ile yürütülen ve ConnectionManager nesneleri eklenen paket ek işlevsellik sunarBu bölümde program aracılığıyla bir paket oluşturmak nasıl açıklar.Görevler oluşturma hakkında bilgi sağlamak veya ConnectionManager.Bunlar daha sonraki bölümlerde açıklanmıştır.

Örnek

Visual Studio IDE kullanarak kod yazmak için bir başvuru Microsoft.SqlServer.ManagedDTS.DLL oluşturmak için gerekli bir using deyim (Imports Visual Basic.net) Microsoft.SqlServer.Dts.Runtime.Aşağıdaki kod örneği, bir boş paket oluşturma gösterir.

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

namespace Microsoft.SqlServer.Dts.Samples
{
  class Program
  {
    static void Main(string[] args)
    {
      Package package;
      package = new Package();
    }
  }
}
Imports Microsoft.SqlServer.Dts.Runtime

Module Module1

  Sub Main()

    Dim package As Package
    package = New Package

  End Sub

End Module

Derleyip örneği çalıştırmak için Visual Studio F5 tuşuna basın.C# derleyicisi kullanarak kodu oluşturmak için CSC.exe'de, derlemek için komut istemi isteminde aşağıdaki komutu kullanın ve başvuruları değiştirme, dosya <filename> .cs veya .vb dosya ve onu vererek adını taşıyan bir <outputfilename> seçim.

CSC /hedef:library/out: <outputfilename>.dll <dosya adı>.cs /r:Microsoft.SqlServer.Managed DTS.dll " /r:System.dll

Visual Basic kullanarak kod oluşturmak için.net derleyici vbc.exe, derlemek için komut istemi isteminde aşağıdaki komutu kullanın ve dosya başvurusu.

Vbc /hedef:library/out: <outputfilename>.dll <dosya adı>.vb /r:Microsoft.SqlServer.Managed DTS.dll " /r:System.dll

Disk üzerindeki dosya sistemi veya için kaydedilmiş olan var olan paket yükleyerek paket oluşturabilirsiniz SQL Server.Farkı olan Application nesnesini oluşturan önce ve sonra paket nesne aşırı yüklenmiş yöntemler uygulamanın biri tarafından doldurulur: LoadPackagedüz dosyalar için LoadFromSQLServer için kaydedilen paketleri için SQL Server, veya LoadFromDtsServer paketlerinin kaydedilen dosya sistemi.Aşağıdaki örnek, diskteki varolan bir paketi yükler ve ardından paket üzerinde çeşitli özelliklerini görüntüler.

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

namespace Microsoft.SqlServer.Dts.Samples
{
  class ApplicationTests
  {
    static void Main(string[] args)
    {
      // The variable pkg points to the location of the
      // ExecuteProcess package sample that was installed with
      // the SSIS samples.
      string pkg = @"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services" +
        @"\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx";

      Application app = new Application();
      Package p = app.LoadPackage(pkg, null);

      // Now that the package is loaded, we can query on
      // its properties.
      int n = p.Configurations.Count;
      DtsProperty p2 = p.Properties["VersionGUID"];
      DTSProtectionLevel pl = p.ProtectionLevel;

      Console.WriteLine("Number of configurations = " + n.ToString());
      Console.WriteLine("VersionGUID = " + (string)p2.GetValue(p));
      Console.WriteLine("ProtectionLevel = " + pl.ToString());
      Console.Read();
    }
  }
}
Imports Microsoft.SqlServer.Dts.Runtime

Module ApplicationTests

  Sub Main()

    ' The variable pkg points to the location of the
    ' ExecuteProcess package sample that was installed with
    ' the SSIS samples.
    Dim pkg As String = _
      "C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services" & _
      "\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"

    Dim app As Application = New Application()
    Dim p As Package = app.LoadPackage(pkg, Nothing)

    ' Now that the package is loaded, we can query on
    ' its properties.
    Dim n As Integer = p.Configurations.Count
    Dim p2 As DtsProperty = p.Properties("VersionGUID")
    Dim pl As DTSProtectionLevel = p.ProtectionLevel

    Console.WriteLine("Number of configurations = " & n.ToString())
    Console.WriteLine("VersionGUID = " & CType(p2.GetValue(p), String))
    Console.WriteLine("ProtectionLevel = " & pl.ToString())
    Console.Read()

  End Sub

End Module

Örnek Çıktı:

Number of configurations = 2

VersionGUID = {09016682-89B8-4406-AAC9-AF1E527FF50F}

ProtectionLevel = DontSaveSensitive

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

En son karşıdan yüklemeler, makaleler, örnekler ve seçilen topluluk çözümleri yanı sıra Microsoft videolar için ziyaret Integration Services sayfa msdn veya TechNet:

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