Click to Rate and Give Feedback
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
ScriptObjectModel.Connections Property

Returns the Connections collection of existing connections defined in the package that contains the Script task.

Namespace: Microsoft.SqlServer.Dts.Tasks.ScriptTask
Assembly: Microsoft.SqlServer.ScriptTask (in microsoft.sqlserver.scripttask.dll)
VisualBasicDeclaration
Public ReadOnly Property Connections As Connections
CSharp
public Connections Connections { get; }
ManagedCPlusPlus
public:
property Connections^ Connections {
    Connections^ get ();
}
JSharp
/** @property */
public Connections get_Connections ()
JScript
public function get Connections () : Connections

Property Value

The Connections collection of existing connections defined in the package that contains the Script task.

Use the Connections property of the Dts object in Script task code to access connection managers defined in the package.


The following sample of code for use inside a Script task demonstrates how to access connection managers from within the Script task. The sample assumes that you have created and configured an ADO.NET connection manager named Test ADO.NET Connection and a Flat File connection manager named Test Flat File Connection. Note that the ADO.NET connection manager returns a SqlConnection object that you can use immediately to connect to the data source. The Flat File connection manager, on the other hand, returns only a string that contains the path and filename. You must use methods from the System.IO namespace to open and work with the flat file.

VisualBasic
Public Sub Main()

    Dim myADONETConnection As SqlClient.SqlConnection
    myADONETConnection = _
        DirectCast(Dts.Connections("Test ADO.NET Connection").AcquireConnection(Dts.Transaction), _
        SqlClient.SqlConnection)
    MsgBox(myADONETConnection.ConnectionString, _
        MsgBoxStyle.Information, "ADO.NET Connection")

    Dim myFlatFileConnection As String
    myFlatFileConnection = _
        DirectCast(Dts.Connections("Test Flat File Connection").AcquireConnection(Dts.Transaction), _
        String)
    MsgBox(myFlatFileConnection, MsgBoxStyle.Information, "Flat File Connection")

    Dts.TaskResult = Dts.Results.Success

End Sub
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

For a list of the supported platforms, see Hardware and Software Requirements for Installing SQL Server 2005.

Target Platforms

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker