Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ScriptObjectModel Class

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

Namespace:  Microsoft.SqlServer.Dts.Tasks.ScriptTask
Assembly:  Microsoft.SqlServer.ScriptTask (in Microsoft.SqlServer.ScriptTask.dll)
'Declaration
Public Class ScriptObjectModel
'Usage
Dim instance As ScriptObjectModel

The ScriptObjectModel type exposes the following members.

  NameDescription
Public propertyConnectionsReturns the Connections collection of existing connections defined in the package that contains the Script task.
Public propertyEventsReturns the IDTSComponentEvents collection of existing events defined in the package that contains the Script task.
Public propertyExecutionValueGets or sets a user-defined object that provides additional information about the results of task execution.
Public propertyTaskResultReturns the DTSExecResult of the Script task.
Public propertyTransactionReturns the transaction associated with the container of the Script task.
Public propertyVariableDispenserReturns the VariableDispenser that can be used within the Script task to work with existing variables.
Public propertyVariablesReturns the Variables collection of existing variables defined in the package that contains the Script task.
Top
  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Public methodLogLogs an entry to all enabled log providers.
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

Within the Microsoft Visual Studio 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 Querying the Active Directory with the Script Task.

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
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.