次の方法で共有


Package.Warnings Property

パッケージに設定された警告のコレクションを返します。このフィールドは読み取り専用です。

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

構文

'宣言
<BrowsableAttribute(False)> _
Public ReadOnly Property Warnings As DtsWarnings
[BrowsableAttribute(false)] 
public DtsWarnings Warnings { get; }
[BrowsableAttribute(false)] 
public:
property DtsWarnings^ Warnings {
    DtsWarnings^ get ();
}
/** @property */
public DtsWarnings get_Warnings ()
public function get Warnings () : DtsWarnings

プロパティ値

DtsWarnings コレクションです。

使用例

次のコード例では、パッケージに 2 つのタスクを追加し、それぞれに警告を設定します。さらにコード例では、警告がパッケージの Warnings コレクションに追加されたことを示します。

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

namespace DtsWarning_API
{
    class Program
    {
        static void Main(string[] args)
        {
            Package package = new Package();
            int pkgWarnCnt = package.Warnings.Count;
            Console.WriteLine("Package warnings count:  {0}", pkgWarnCnt);

            TaskHost taskH1 = (TaskHost)package.Executables.Add("STOCK:BulkInsertTask");
            TaskHost taskH2 = (TaskHost)package.Executables.Add("STOCK:SendMailTask");
            DtsEventHandler eh = (DtsEventHandler)taskH1.EventHandlers.Add("OnWarning");
            eh = (DtsEventHandler)taskH2.EventHandlers.Add("OnWarning");

            // Test that errors were successfully be added to the collection
            package.Execute();

            if (package.Warnings.Count >= 2)
            {
                pkgWarnCnt = package.Warnings.Count;
                Console.WriteLine("Package warnings count after:  {0}", pkgWarnCnt);
                Console.WriteLine("Description {0}", package.Warnings[0].Description);
                Console.WriteLine("WarningCode {0}", package.Warnings[0].WarningCode);
                Console.WriteLine("HelpContext {0}", package.Warnings[0].HelpContext);
                Console.WriteLine("HelpFile {0}", package.Warnings[0].HelpFile);
                Console.WriteLine("IDOfInterfaceWithWarning {0}", package.Warnings[0].IDOfInterfaceWithWarning);

                Console.WriteLine("Test that Warnings can be added to the collection, TRUE");
            }
            else
                Console.WriteLine("Test that Warnings can be added to the collection, FAILED");
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Dts.Tasks.BulkInsertTask
Imports Microsoft.SqlServer.Dts.Tasks.SendMailTask
 
Namespace DtsWarning_API
    Class Program
        Shared  Sub Main(ByVal args() As String)
            Dim package As Package =  New Package() 
            Dim pkgWarnCnt As Integer =  package.Warnings.Count 
            Console.WriteLine("Package warnings count:  {0}", pkgWarnCnt)
 
            Dim taskH1 As TaskHost = CType(package.Executables.Add("STOCK:BulkInsertTask"), TaskHost)
            Dim taskH2 As TaskHost = CType(package.Executables.Add("STOCK:SendMailTask"), TaskHost)
            Dim eh As DtsEventHandler = CType(taskH1.EventHandlers.Add("OnWarning"), DtsEventHandler)
            eh = CType(taskH2.EventHandlers.Add("OnWarning"), DtsEventHandler)
 
            ' Test that errors were successfully be added to the collection
            package.Execute()
 
            If package.Warnings.Count >= 2 Then
                pkgWarnCnt = package.Warnings.Count
                Console.WriteLine("Package warnings count after:  {0}", pkgWarnCnt)
                Console.WriteLine("Description {0}", package.Warnings(0).Description)
                Console.WriteLine("WarningCode {0}", package.Warnings(0).WarningCode)
                Console.WriteLine("HelpContext {0}", package.Warnings(0).HelpContext)
                Console.WriteLine("HelpFile {0}", package.Warnings(0).HelpFile)
                Console.WriteLine("IDOfInterfaceWithWarning {0}", package.Warnings(0).IDOfInterfaceWithWarning)
                Console.WriteLine("Test that Warnings can be added to the collection, TRUE")
            Else 
                Console.WriteLine("Test that Warnings can be added to the collection, FAILED")
            End If
        End Sub
    End Class
End Namespace

サンプルの出力 :

Package warnings count: 0

Package warnings count after: 2

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

WarningCode 0

HelpContext 0

HelpFile

IDOfInterfaceWithWarning {8BDFE893-E9D8-4D23-9739-DA807BCDC2AC}

Test that Warnings can be added to the collection, TRUE

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

Package Class
Package Members
Microsoft.SqlServer.Dts.Runtime Namespace