次の方法で共有


DtsEnumerator.MoveNext メソッド

コレクションの次の要素に列挙子を進めます。

名前空間:  Microsoft.SqlServer.Dts.Runtime
アセンブリ:  Microsoft.SqlServer.ManagedDTS (Microsoft.SqlServer.ManagedDTS.dll)

構文

'宣言
Public Function MoveNext As Boolean
'使用
Dim instance As DtsEnumerator 
Dim returnValue As Boolean 

returnValue = instance.MoveNext()
public bool MoveNext()
public:
virtual bool MoveNext() sealed
abstract MoveNext : unit -> bool  
override MoveNext : unit -> bool
public final function MoveNext() : boolean

戻り値

型: System.Boolean
列挙子が次の要素に正常に進んだ場合は true。列挙子がコレクションの末尾を越えた場合は false。

実装

IEnumerator.MoveNext()

説明

列挙子の作成後、または Reset メソッドの呼び出し後は、列挙子はコレクションの先頭の要素の前に配置され、最初に MoveNext を呼び出したときに、コレクションの先頭の要素に移動します。

列挙子がコレクションの末尾を越えた後で、Reset を呼び出すまでは、MoveNext を呼び出すと、false が返されます。

列挙子は、コレクションが変更されない限り有効です。 要素の追加、変更、削除など、コレクションに変更が加えられた場合は、列挙子は無効になり回復できなくなります。そのため、次の MoveNext または Reset の呼び出しで InvalidOperationException がスローされます。

使用例

次のコード例では、タスクをパッケージに追加してから、パッケージを実行します。 警告コレクションは、この DtsEnumerator クラスを継承する WarningEnumerator を作成することによって作成され、Current メソッドと MoveNext メソッドを使用してコレクションの警告を確認することによって、各警告の説明を表示します。

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

namespace Microsoft.SqlServer.SSIS.Samples
{
    class Program
    {
        static void Main(string[] args)
        {
            Package package = new Package();
            Console.WriteLine("Package warnings count before running: {0}", package.Warnings.Count);

            TaskHost taskH2 = (TaskHost)package.Executables.Add("STOCK:SendMailTask");
            taskH2.FailPackageOnFailure = false;
            taskH2.FailParentOnFailure = false;
            Console.WriteLine("SendMailTask: {0}", taskH2.ID);
 
            // Test that warnings were successfully added to the collection.
            package.MaximumErrorCount = 100;
            package.FailPackageOnFailure = false;
            package.FailParentOnFailure = false;
            package.DelayValidation = true;
            package.Execute();

            Console.WriteLine("Package warnings count after running the package: {0}", package.Warnings.Count);

            // Create the enumerator.
            WarningEnumerator myEnumerator = package.Warnings.GetEnumerator();
            Console.WriteLine("The collection contains the following values:");
            int i = 0;
            while ((myEnumerator.MoveNext()) && (myEnumerator.Current != null))
                Console.WriteLine("[{0}] {1}", i++, myEnumerator.Current.Description);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask
 
Namespace Microsoft.SqlServer.SSIS.Samples
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim package As Package =  New Package() 
            Console.WriteLine("Package warnings count before running: {0}", package.Warnings.Count)
 
            Dim taskH2 As TaskHost = CType(package.Executables.Add("STOCK:SendMailTask"), TaskHost)
            taskH2.FailPackageOnFailure = False
            taskH2.FailParentOnFailure = False
            Console.WriteLine("SendMailTask: {0}", taskH2.ID)
 
            ' Test that warnings were successfully added to the collection.
            package.MaximumErrorCount = 100
            package.FailPackageOnFailure = False
            package.FailParentOnFailure = False
            package.DelayValidation = True
            package.Execute()
 
            Console.WriteLine("Package warnings count after running the package: {0}", package.Warnings.Count)
 
            ' Create the enumerator.
            Dim myEnumerator As WarningEnumerator =  package.Warnings.GetEnumerator() 
            Console.WriteLine("The collection contains the following values:")
            Dim i As Integer =  0 
            While (myEnumerator.MoveNext()) &&(myEnumerator.Current <> Nothing)
                Console.WriteLine("[{0}] {1}",i = Console.WriteLine("[{0}] {1}",i + 1
            End While
        End Sub
    End Class
End Namespace

サンプルの出力 :

Package warnings count before running: 0

SendMailTask: {34CAEFF9-64BF-401D-B646-C88B705DB971}

Package warnings count after running the package: 2

The collection contains the following values:

[0] The address in the From line is not formed correctly. It is missing an @ or it is not valid.

[1] Subject is empty

関連項目

参照

DtsEnumerator クラス

Microsoft.SqlServer.Dts.Runtime 名前空間