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

PackageNesnesi olan tüm diğer nesneler için üst düzey kapsayıcı bir SSISProje çözüm. Üst düzey kapsayıcı olarak paket, oluşturulan ilk nesnesidir ve sonraki nesneler ekledi ve sonra paketi kapsamında yürütülen. Paket taşımayın veya verileri dönüştürmek. Görevleri paketi dayanıyor bu işi gerçekleştirmek için içerir. Görevler bir paket tarafından gerçekleştirilen işlerin çoğunu gerçekleştirmek ve bir paket işlevselliğini tanımlayın. Bir paketi oluşturulur ve sadece üç satır kodu, ama çeşitli görevleri ile yürütülen ve ConnectionManagernesneleri paketinize ek işlevsellik sağlamak için eklenir. Bu bölüm, program aracılığıyla bir paket oluşturmak nasıl anlatılmaktadır. Görevler oluşturma hakkında bilgi sağlamaz 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 gereklidir a usingdeyimi ( Imports Visual Basic.net) Microsoft.SqlServer.Dts.Runtime. Aşağıdaki kod örneği, bir boş paket oluşturma gösterilmiştir.

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

namespace Microsoft.SqlServer.Dts.Samples
{
  class Program
  {
    static void Main(string[] args)
    {
      Package package;
      package = new Package();
    }
  }
}
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
Imports Microsoft.SqlServer.Dts.Runtime

Module Module1

  Sub Main()

    Dim package As Package
    package = New Package

  End Sub

End Module

Örneği çalıştırmak ve derlemek için Visual Studio'da F5 tuşuna basın. C# derleyicisi kullanarak kodu oluşturmak için csc.exe, derlemek için komut isteminde aşağıdaki komutu kullanın ve dosya değiştirme başvuruları, <filename>ve onu veren .cs veya .vb dosyası adını taşıyan bir <outputfilename>dilediğiniz.

csc /target:library /out: <outputfilename>.dll <filename>.cs /r:Microsoft.SqlServer.Managed DTS.dll" /r:System.dll

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

vbc /target:library /out: <outputfilename>.dll <filename>.vb /r:Microsoft.SqlServer.Managed DTS.dll" /r:System.dll

Diskteki dosya sistemi, ya da kaydedilmiş varolan paketi yükleyerek bir paketi oluşturabilirsiniz SQL Server. Fark Applicationnesne ilk oluşturulma ve sonra paketi nesne bir uygulamanın aşırı yüklenmiş yöntemler tarafından doldurulur: LoadPackagedüz dosyalar için LoadFromSQLServerkaydedilen paketleri SQL Server, ya LoadFromDtsServerdosya sistemine kayıtlı paketleri için. Aşağıdaki örnek diskteki varolan bir paketi yükler ve sonra paketi çeşitli özellikler 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();
    }
  }
}
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
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

Dış Kaynaklar

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

Görevleri program aracılığıyla ekleme