Configurations.MoveBefore(Object, Configuration) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Verschiebt ein Configuration-Objekt an eine Stelle vor einem vorhandenen Configuration-Objekt.
public:
void MoveBefore(System::Object ^ index, Microsoft::SqlServer::Dts::Runtime::Configuration ^ config);
public void MoveBefore (object index, Microsoft.SqlServer.Dts.Runtime.Configuration config);
member this.MoveBefore : obj * Microsoft.SqlServer.Dts.Runtime.Configuration -> unit
Public Sub MoveBefore (index As Object, config As Configuration)
Parameter
- index
- Object
Der Name bzw. die Beschreibung, ID oder Identität eines bereits in der Auflistung enthaltenen Configuration-Objekts.
- config
- Configuration
Das Configuration-Objekt, das in der Auflistung verschoben werden soll.
Beispiele
Im folgenden Codebeispiel werden drei Konfigurationen erstellt und einem Paket hinzugefügt. Anschließend wird der Name angezeigt, und die Namen werden in der Reihenfolge angezeigt, in der sie hinzugefügt wurden. Mit der MoveBefore Methode wird die Konfiguration in der letzten Position, Indexposition 2, an die Vorderseite der Auflistung verschoben, bevor sich die Konfiguration in Indexposition 0 befindet. Die Namen werden erneut angezeigt und Conf3
werden jetzt in die Position vor Conf1
der Auflistung verschoben.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SqlServer.Dts.Runtime;
namespace Configurations_API
{
class Program
{
static void Main(string[] args)
{
Package p = new Package();
Configuration conf1 = p.Configurations.Add();
conf1.ConfigurationString = "Conf1 Configuration String";
conf1.ConfigurationType = DTSConfigurationType.EnvVariable;
conf1.Description = "Some description for Conf1 configuration";
conf1.Name = "Conf1";
conf1.PackagePath = "A Variable Name in configuration Conf1";
Configuration conf2 = p.Configurations.Add();
conf2.ConfigurationString = "Conf2 Configuration String";
conf2.ConfigurationType = DTSConfigurationType.ConfigFile;
conf2.Description = "Some description for Conf2 configuration";
conf2.Name = "Conf2";
conf2.PackagePath = "A Variable Name in configuration Conf2";
Configuration conf3 = p.Configurations.Add();
conf3.ConfigurationString = "Conf3 Configuration String2";
conf3.ConfigurationType = DTSConfigurationType.RegEntry;
conf3.Description = "Conf3 description for Conf3 configuration2";
conf3.Name = "Conf3";
conf3.PackagePath = "A Variable Name in configuration Conf3";
DTSExecResult pkgExecResults = p.Execute();
if (pkgExecResults == DTSExecResult.Success)
{
Console.WriteLine("Success!");
// Iterate over the configurations.
Configurations configs = p.Configurations;
foreach (Configuration config in configs)
{
// This is an ordered collection, they display in the order added.
Console.WriteLine("Configuration Name {0}", config.Name);
}
Console.WriteLine("---------------------------------------------------");
// Using the Configurations methods, move the configurations around.
Configuration movingConfig = p.Configurations[2];
p.Configurations.MoveBefore(0, movingConfig);
foreach (Configuration config in configs)
{
Console.WriteLine("Configuration Name {0}", config.Name);
}
Console.WriteLine("---------------------------------------------------");
}
else
{
Console.WriteLine("Results were {0}", pkgExecResults);
}
Console.WriteLine("Number of configuration in package {0}", p.Configurations.Count);
}
}
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Namespace Configurations_API
Class Program
Shared Sub Main(ByVal args() As String)
Dim p As Package = New Package()
Dim conf1 As Configuration = p.Configurations.Add()
conf1.ConfigurationString = "Conf1 Configuration String"
conf1.ConfigurationType = DTSConfigurationType.EnvVariable
conf1.Description = "Some description for Conf1 configuration"
conf1.Name = "Conf1"
conf1.PackagePath = "A Variable Name in configuration Conf1"
Dim conf2 As Configuration = p.Configurations.Add()
conf2.ConfigurationString = "Conf2 Configuration String"
conf2.ConfigurationType = DTSConfigurationType.ConfigFile
conf2.Description = "Some description for Conf2 configuration"
conf2.Name = "Conf2"
conf2.PackagePath = "A Variable Name in configuration Conf2"
Dim conf3 As Configuration = p.Configurations.Add()
conf3.ConfigurationString = "Conf3 Configuration String2"
conf3.ConfigurationType = DTSConfigurationType.RegEnTry
conf3.Description = "Conf3 description for Conf3 configuration2"
conf3.Name = "Conf3"
conf3.PackagePath = "A Variable Name in configuration Conf3"
Dim pkgExecResults As DTSExecResult = p.Execute()
If pkgExecResults = DTSExecResult.Success Then
Console.WriteLine("Success!")
' Iterate over the configurations.
Dim configs As Configurations = p.Configurations
Dim config As Configuration
For Each config In configs
' This is an ordered collection, they display in the order added.
Console.WriteLine("Configuration Name {0}", config.Name)
Next
Console.WriteLine("---------------------------------------------------")
' Using the Configurations methods, move the configurations around.
Dim movingConfig As Configuration = p.Configurations(2)
p.Configurations.MoveBefore(0, movingConfig)
Dim config As Configuration
For Each config In configs
Console.WriteLine("Configuration Name {0}", config.Name)
Next
Console.WriteLine("---------------------------------------------------")
Else
Console.WriteLine("Results were {0}", pkgExecResults)
End If
Console.WriteLine("Number of configuration in package {0}", p.Configurations.Count)
End Sub
End Class
End Namespace
Beispielausgabe:
Der Vorgang war erfolgreich.
Konfigurationsname Conf1
Konfigurationsname Conf2
Konfigurationsname Conf3
---------------------------------------------------
Konfigurationsname Conf3
Konfigurationsname Conf1
Konfigurationsname Conf2
---------------------------------------------------
Anzahl der Konfiguration in Paket 3
Hinweise
Verschiebt das Configuration Objekt in der Auflistung. Die neue Position befindet sich vor dem durch den index
Parameter angegebenen Objekt.