XMLTask.Validate Method

Definition

Verifies that the component is properly configured.

public:
 override Microsoft::SqlServer::Dts::Runtime::DTSExecResult Validate(Microsoft::SqlServer::Dts::Runtime::Connections ^ connections, Microsoft::SqlServer::Dts::Runtime::VariableDispenser ^ variableDispenser, Microsoft::SqlServer::Dts::Runtime::IDTSComponentEvents ^ events, Microsoft::SqlServer::Dts::Runtime::IDTSLogging ^ log);
public override Microsoft.SqlServer.Dts.Runtime.DTSExecResult Validate (Microsoft.SqlServer.Dts.Runtime.Connections connections, Microsoft.SqlServer.Dts.Runtime.VariableDispenser variableDispenser, Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents events, Microsoft.SqlServer.Dts.Runtime.IDTSLogging log);
override this.Validate : Microsoft.SqlServer.Dts.Runtime.Connections * Microsoft.SqlServer.Dts.Runtime.VariableDispenser * Microsoft.SqlServer.Dts.Runtime.IDTSComponentEvents * Microsoft.SqlServer.Dts.Runtime.IDTSLogging -> Microsoft.SqlServer.Dts.Runtime.DTSExecResult
Public Overrides Function Validate (connections As Connections, variableDispenser As VariableDispenser, events As IDTSComponentEvents, log As IDTSLogging) As DTSExecResult

Parameters

connections
Connections

A collection of Connections used by the task.

variableDispenser
VariableDispenser

A VariableDispenser object for locking variables.

events
IDTSComponentEvents

An object that implements the IDTSComponentEvents interface.

log
IDTSLogging

An object that implements the IDTSLogging interface.

Returns

A value from the DTSExecResult enumeration.

Examples

The following code example creates an XMLTask as part of a package. After the task is created, it sets several properties, and then calls the Validate method of the Package.

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

namespace XMLTask_API  
{  
        class Program  
        {  
        static void Main(string[] args)  

            // Set up the objects and tasks.  
            Package pkg = new Package();  
            Executable exec1 = pkg.Executables.Add("STOCK:XMLTask");  
            TaskHost th = exec1 as TaskHost;  
            XMLTask myTask = th.InnerObject as XMLTask;  

            // Create a FILE connection manager to books.xml.  
            ConnectionManager connMgr = pkg.Connections.Add("FILE");  
            connMgr.Name = "XMLConnectionManager";  
            // The file, Books.xml, is stored on the C:\ drive.  
            connMgr.ConnectionString = @"c:\books.xml";  

            // Set the XMLTask properties.  
            myTask.OperationType = DTSXMLOperation.Validate;  
            myTask.SourceType = DTSXMLSourceType.FileConnection;  
            myTask.Source = connMgr.Name;  

            DTSExecResult valResults = pkg.Validate(pkg.Connections, pkg.Variables, null, null);  
            Console.WriteLine("RESULTS: {0}", valResults);  
        }  
    }  
}  

Sample output:

RESULTS: Success

Remarks

This method is available to the XMLTask, regardless of the OperationType value.

The Validate method reviews properties and settings for inaccuracies or incorrect settings. The method does not touch data, or connect to data sources to validate connections. However, it ensures that required fields are populated and contain appropriate values. The fields that are validated differ depending on what object is being validated.

The primary use of Validate is when writing a custom task. The Validate method is called by the SSIS Designer when a task is dropped onto the design surface and again, potentially multiple times, when properties are being set. However, in code, the Validate method on individual objects is not commonly used, as it is recommended that you call the Validate method on the Package when you need to validate objects. However, the method is available on individual objects should you find a unique circumstance where it is needed.

The Validate method is overridden in custom tasks, either for validation of the object when used in the SSIS Designer, or when called by code. For more information on writing the Validate method for a custom task, see Coding a Custom Task.

Applies to