DTSXMLSourceType 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
描述 SourceType中 的 、XPath 字串 XPathStringSourceType的來源類型,以及 中 SecondOperandType第二個運算元的類型。 根據所使用的類型, Source、 XPathStringSource、 和 SecondOperand 屬性必須相容。 例如,若 被 SourceType 設定為 FileConnection,則必須 Source 包含連線管理器。 若 SourceType 為 Variable,則 Source 必須指向要使用的變數。
public enum class DTSXMLSourceType
public enum DTSXMLSourceType
type DTSXMLSourceType =
Public Enum DTSXMLSourceType
- 繼承
-
DTSXMLSourceType
欄位
| 名稱 | 值 | Description |
|---|---|---|
| FileConnection | 0 | 指定 XML 文件儲存在檔案中。 該任務會與連線管理器互動,從檔案中擷取 XML 文件。 如果你正在為此任務撰寫使用者介面,支援檔案連線管理員檢索的操作也應該提供新連線按鈕,讓使用者在編輯任務時能建立新連線。 |
| Variable | 1 | 指定 XML 文件儲存在變數中。 |
| DirectInput | 2 | 規定 XML 文件以純文字直接輸入任務使用者介面的某個區域。 此選項僅在提供任務使用者介面時使用。 |
範例
以下程式碼範例展示了使用此枚舉來設定 SourceType 任務的 和 SecondOperandType 。
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;
// You can cast the InnerObject to the XmlTask,
// but it is advised that you work with tasks
// through the TaskHost and its Properties.
// XMLTask myTask = th.InnerObject as XMLTask;
// Create a variable and a FILE connection
// manager to books.xml.
Variable resultVar = pkg.Variables.Add("resultVariable", false, "", "Variable for the result");
ConnectionManager connMgr = pkg.Connections.Add("FILE");
connMgr.Name = "XMLConnectionManager";
// The file is stored on the C:\ drive.
connMgr.ConnectionString = @"c:\books.xml";
// Set the XMLTask properties.
// The first property to set is the
// OperationType. Depending on the
// OperationType, different properties are
// valid.
// The operation type in this example is
// VALIDATE.
th.Properties["OperationType"].SetValue(th, DTSXMLOperation.Validate);
th.Properties["SourceType"].SetValue(th, DTSXMLSourceType.FileConnection);
th.Properties["Source"].SetValue(th, connMgr.Name);
th.Properties["OverwriteDestination"].SetValue(th, true);
th.Properties["SaveOperationResult"].SetValue(th, true);
th.Properties["DestinationType"].SetValue(th, DTSXMLSaveResultTo.Variable);
th.Properties["Destination"].SetValue(th, resultVar.Name);
th.Properties["SecondOperandType"].SetValue(th, DTSXMLSourceType.DirectInput);
th.Properties["SecondOperand"].SetValue(th, "<x></x>");
th.Properties["ValidationType"].SetValue(th, DTSXMLValidationType.DTD);
th.Properties["FailOnValidationFaile"].SetValue(th, true);
DTSExecResult valResults = pkg.Validate(pkg.Connections, pkg.Variables, null, null);
Console.WriteLine("RESULTS: {0}", valResults);
}
}
}
範例輸出:
結果:成功