Configurations.InsertAfter メソッド
Configuration オブジェクトをコレクションの既存の Configuration オブジェクトの後に追加します。
名前空間: Microsoft.SqlServer.Dts.Runtime
アセンブリ: Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)
構文
'宣言
Public Sub InsertAfter ( _
index As Object, _
config As Configuration _
)
'使用
Dim instance As Configurations
Dim index As Object
Dim config As Configuration
instance.InsertAfter(index, config)
public void InsertAfter(
Object index,
Configuration config
)
public:
void InsertAfter(
Object^ index,
Configuration^ config
)
member InsertAfter :
index:Object *
config:Configuration -> unit
public function InsertAfter(
index : Object,
config : Configuration
)
パラメーター
- index
型: System.Object
コレクションに既にある Configuration オブジェクトの名前、説明、または ID です。
- config
型: Microsoft.SqlServer.Dts.Runtime.Configuration
コレクションに挿入する Configuration オブジェクトです。
説明
Configuration オブジェクトをコレクションに挿入します。 新しい位置は、index パラメーターで指定したオブジェクトの後です。
使用例
次のコード例では、3 つの構成を作成し、これらを 1 つのパッケージに追加します。 次に、それらの構成の名前を表示します。名前は、追加した順に表示されます。 InsertAfter を使用して、インデックス位置 1 にある構成の後に、位置 0 の最初の構成が挿入されます。 再度名前が表示され、Conf1 がコレクションの Conf2 の後にコピーとして表示されます。
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[0];
p.Configurations.InsertAfter(1, 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(0)
p.Configurations.InsertAfter(1, 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
サンプル出力:
Success!
Configuration Name Conf1
Configuration Name Conf2
Configuration Name Conf3
---------------------------------------------------
Configuration Name Conf1
Configuration Name Conf2
Configuration Name Conf1
Configuration Name Conf3
---------------------------------------------------
number of configuration in package 4