Retrieve existing connection string info

  • I'm trying to retrieve the connection string of an existing connection manager. so that I can use it in a error handler and output the path that the flat file used for it's connection string in the error that is sent.

    I have the path being populated dynamically with configurations. I am trying to get the Connection string property value from the existing connection string in a script task in an error handler. any suggestions..

    I've been looking at setting a dimming a variable and assigning it to the Connections or connectioninfo or something like that... ie..

    Dim conns As Configurations

    MsgBox(conns.Item("flatfileconn").ConfigurationString.ToString)

    or

    msgbox(conns.count.tostring)

    but it's not working.. It doesn't look like it's getting the existing connections..

    they are giving me this error.. :

    startIndex cannot be larger than length of string.

    Parameter name: startIndex

    like their are no connections...

  • Ok,, for a script task I got it..

    Dim myFlatFileConnection As String

    myFlatFileConnection = _

    DirectCast(Dts.Connections("FlatFileSource").AcquireConnection(Dts.Transaction), _

    String)

    MsgBox(myFlatFileConnection, MsgBoxStyle.Information, "Flat File Connection")

    from there you could assign it to a string or whatever...

  • Try

    Dim connection As ConnectionManager

    connection = Dts.Connections("flatfileconn")

    ' Store it in a defined variable flatfileconnString

    Dts.Variables("flatfileconnString").Value = connection.Properties("ConnectionString").GetValue(connection)

    ' Or display

    MsgBox(CStr(connection.Properties("ConnectionString").GetValue(connection)))

    Success

    Peter

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply