XMLTask.Validate 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
验证组件配置正确。
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
参数
- connections
- Connections
任务中使用的 Connections 集合。
- variableDispenser
- VariableDispenser
一个 VariableDispenser 用于锁定变量的对象。
- events
- IDTSComponentEvents
实现 IDTSComponentEvents 接口的对象。
- log
- IDTSLogging
实现 IDTSLogging 接口的对象。
返回
枚举中的 DTSExecResult 值。
示例
以下代码示例将 作为包的一部分创建。XMLTask 任务创建后,它设置若干属性,然后调用 ValidatePackage的方法。
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);
}
}
}
示例输出:
RESULTS: Success
注解
该方法对 ,无论值如何OperationType,都可用XMLTask。
该 Validate 方法会审查属性和设置的不准确或错误设置。 该方法不接触数据,也不连接数据源以验证连接。 但它确保所需字段被填充并包含适当的值。 被验证的字段因被验证对象而异。
主要用途 Validate 是在编写自定义任务时。 当任务被丢到设计表面时,SSIS设计师会调用该 Validate 方法,在设置属性时也可能多次调用。 然而,在代码中,针对单个对象的方法 Validate 并不常用,因为建议你 Validate 在需要验证对象时调用该方法 Package 。 不过,如果你遇到特殊情况,这种方法也可以在单个物体上使用。
Validate该方法在自定义任务中被覆盖,无论是在 SSIS 设计器中使用时用于验证对象,还是在代码调用时。 关于为自定义任务编写 Validate 方法的更多信息,请参见 “自定义任务编码”。