Freigeben über


Configuration.ConfigurationString Eigenschaft

Definition

Ruft den Speicherort der Konfiguration ab oder legt ihn fest.

public:
 property System::String ^ ConfigurationString { System::String ^ get(); void set(System::String ^ value); };
public string ConfigurationString { get; set; }
member this.ConfigurationString : string with get, set
Public Property ConfigurationString As String

Eigenschaftswert

Eine Zeichenfolge, die den Speicherort der Konfiguration enthält. Der Speicherort kann einem Pfad, einer Umgebungsvariablen, dem Namen einer Variablen eines übergeordneten Pakets oder einem Registrierungsschlüssel entsprechen.

Beispiele

Im folgenden Codebeispiel wird ein Paket erstellt, Konfigurationen aktiviert und der Export der Konfigurationsdatei aktiviert. Sie fügt der Paketsammlung Configurations ein neues Configuration Element hinzu und legt mehrere Eigenschaften für die Konfiguration fest. Nach dem Speichern und Laden des Pakets werden die Konfigurationseigenschaften angezeigt.

using System;  
using System.Collections.Generic;  
using System.Text;  
using Microsoft.SqlServer.Dts.Runtime;  
using Microsoft.SqlServer.Dts.Tasks.BulkInsertTask;  

namespace configuration_API  
{  
    class Program  
    {      
        static void Main(string[] args)  
        {  
        // Create a package and set two properties.  
            Package pkg = new Package();  
            pkg.EnableConfigurations = true;  
            pkg.ExportConfigurationFile(@"C:\conf.xml");  

            // Create a variable object and add it to the   
            // package Variables collection.  
            Variable varPkg = pkg.Variables.Add("var", false, "", 100);  
            varPkg.Value = 1;  
            string packagePathToVariable = varPkg.GetPackagePath();  

            // Create a configuration object and add it to the   
           // package configuration collection.  
            Configuration config = pkg.Configurations.Add();  

           // Set properties on the configuration object.  
            config.ConfigurationString = "conf.xml";  
            config.Description = "My configuration description";  
            config.ConfigurationType = DTSConfigurationType.ConfigFile;  
            config.PackagePath = packagePathToVariable;  

            // Save the package and its configuration.  
            Application app = new Application();  
            app.SaveToXml(@"c:\pkg.xml", pkg, null);  

            // Reload the package.  
            Package p1 = app.LoadPackage(@"c:\pkg.xml", null);  
            // Review the configuration information.  
            Configurations configs_After = pkg.Configurations;  
            foreach(Configuration confAfter in configs_After)  
            {  
                Console.WriteLine("ConfigurationString is {0}", confAfter.ConfigurationString);  
                Console.WriteLine("ConfigurationType is {0}", confAfter.ConfigurationType);  
                Console.WriteLine("CreationName is {0}", confAfter.CreationName);  
                Console.WriteLine("Description is {0}", confAfter.Description);  
                Console.WriteLine("Assigned ID is {0}", confAfter.ID);  
                Console.WriteLine("Name is {0}", confAfter.Name);  
            }  
        }  
    }  
}  
Imports System  
Imports System.Collections.Generic  
Imports System.Text  
Imports Microsoft.SqlServer.Dts.Runtime  
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask  

Namespace configuration_API  
    Class Program  
        ' Create a package and set two properties.  
            Dim pkg As Package =  New Package()   
            pkg.EnableConfigurations = True  
            pkg.ExportConfigurationFile("C:\conf.xml")  

            ' Create a variable object and add it to the   
            ' package Variables collection.  
            Dim varPkg As Variable =  pkg.Variables.Add("var",False,"",100)   
            varPkg.Value = 1  
            Dim packagePathToVariable As String =  varPkg.GetPackagePath()   

            ' Create a configuration object and add it to the   
           ' package configuration collection.  
            Dim config As Configuration = pkg.Configurations.Add()   

           ' Set properties on the configuration object.  
            config.ConfigurationString = "conf.xml"  
            config.Description = "My configuration description"  
            config.ConfigurationType = DTSConfigurationType.ConfigFile  
            config.PackagePath = packagePathToVariable  

            ' Save the package and its configuration.  
            Dim app As Application = New Application()   
            app.SaveToXml("c:\pkg.xml", pkg, Nothing)  

            ' Reload the package.  
            Dim p1 As Package =  app.LoadPackage("c:\pkg.xml",Nothing)   
            ' Review the configuration information.  
            Dim configs_After As Configurations = pkg.Configurations   
            Dim confAfter As Configuration  
            For Each confAfter In configs_After  
                Console.WriteLine("ConfigurationString is {0}", confAfter.ConfigurationString)  
                Console.WriteLine("ConfigurationType is {0}", confAfter.ConfigurationType)  
                Console.WriteLine("CreationName is {0}", confAfter.CreationName)  
                Console.WriteLine("Description is {0}", confAfter.Description)  
                Console.WriteLine("Assigned ID is {0}", confAfter.ID)  
                Console.WriteLine("Name is {0}", confAfter.Name)  
            Next  
    End Class  
End Namespace  

Beispielausgabe:

Der Wert der Variablen var = 1

ConfigurationString ist conf.xml

ConfigurationType ist ConfigFile

CreationName ist

Beschreibung ist "Meine Konfigurationsbeschreibung"

Zugewiesene ID ist {9CF65E37-0833-44CD-A99D-EBFE38FAB31B}

Name ist {9CF65E37-0833-44CD-A99D-EBFE38FAB31B}

Paketpfad ist \Package.Variables[::var]

Gilt für: