This documentation is archived and is not being maintained.

Package.Warnings Property

Returns a collection of warnings set on the package. This field is read-only.

Namespace: Microsoft.SqlServer.Dts.Runtime
Assembly: Microsoft.SqlServer.ManagedDTS (in microsoft.sqlserver.manageddts.dll)

public DtsWarnings Warnings { get; }
/** @property */
public DtsWarnings get_Warnings ()

public function get Warnings () : DtsWarnings

Property Value

A DtsWarnings collection.

The following code example adds two tasks to the package, and sets a warning on each. The code example then shows that the warnings have also been added to the package Warnings collection.

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

            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");
                Console.WriteLine("Test that Warnings can be added to the collection, FAILED");

Sample Output:

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


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

Test that Warnings can be added to the collection, TRUE

Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms