共用方式為


ScriptObjectModel 類別

Gives the developer of the Script task programmatic access to objects defined in the package through the global Dts object. The Dts object is an instance of the ScriptObjectModel class.

繼承階層

System. . :: . .Object
  Microsoft.SqlServer.Dts.Tasks.ScriptTask..::..ScriptObjectModel

命名空間:  Microsoft.SqlServer.Dts.Tasks.ScriptTask
組件:  Microsoft.SqlServer.ScriptTask (在 Microsoft.SqlServer.ScriptTask.dll 中)

語法

'宣告
Public Class ScriptObjectModel
'用途
Dim instance As ScriptObjectModel
public class ScriptObjectModel
public ref class ScriptObjectModel
type ScriptObjectModel =  class end
public class ScriptObjectModel

ScriptObjectModel 型別公開下列成員。

屬性

  名稱 說明
公用屬性 Connections Returns the Connections collection of existing connections defined in the package that contains the Script task.
公用屬性 Events Returns the IDTSComponentEvents collection of existing events defined in the package that contains the Script task.
公用屬性 ExecutionValue Gets or sets a user-defined object that provides additional information about the results of task execution.
公用屬性 TaskResult Returns the DTSExecResult of the Script task.
公用屬性 Transaction Returns the transaction associated with the container of the Script task.
公用屬性 VariableDispenser Returns the VariableDispenser that can be used within the Script task to work with existing variables.
公用屬性 Variables Returns the Variables collection of existing variables defined in the package that contains the Script task.

上層

方法

  名稱 說明
公用方法 Equals (繼承自 Object。)
受保護的方法 Finalize (繼承自 Object。)
公用方法 GetHashCode (繼承自 Object。)
公用方法 GetType (繼承自 Object。)
公用方法 Log Logs an entry to all enabled log providers.
受保護的方法 MemberwiseClone (繼承自 Object。)
公用方法 ToString (繼承自 Object。)

上層

備註

Within the Microsoft Visual Studio 2008 Tools for Applications (VSTA) scripting environment, the Script task provides the global Dts object, which gives the developer programmatic access to objects defined elsewhere in the package, such as connections, variables, and events, through the properties and methods of the ScriptObjectModel class. The Dts object is an instance of the ScriptObjectModel class.

範例

The following sample of code for use inside a Script task demonstrates the use of the Variables, Events, and TaskResult properties. For more information, see 以指令碼工作查詢 Active Directory.

Public Sub Main()

    Dim directory As DirectoryServices.DirectorySearcher
    Dim result As DirectoryServices.SearchResult
    Dim email As String

    email = Dts.Variables("email").Value.ToString

    Try
        directory = New _
            DirectoryServices.DirectorySearcher("(mail=" & email & ")")
        result = directory.FindOne
        Dts.Variables("name").Value = _
            result.Properties("displayname").ToString
        Dts.Variables("title").Value = _
            result.Properties("title").ToString
        Dts.TaskResult = ScriptResults.Success
    Catch ex As Exception
        Dts.Events.FireError(0, _
            "Script Task Example", _
            ex.Message & ControlChars.CrLf & ex.StackTrace, _
            String.Empty, 0)
        Dts.TaskResult = ScriptResults.Failure
    End Try

End Sub

執行緒安全性

這個型別的任何公用 static (在 Visual Basic 中為 Shared) 成員都是執行緒安全的。並不是所有的執行個體成員都保證可以用於所有的執行緒。