Get ConnectionString from Connection manager – SSIS


Connection string building is vital task for programmer to connect to a database server in Script Task. of course, there is a website that has pre-defined connection strings for all database servers. You can browse connectionStrings here.

But, In this article I will show you how to read the connection string from the connection manager in script task.

Step 1: Create a SSIS package

Step 2: Add a OLE DB connection and connect to your Microsoft SQL Server server.

 

 

 

 

 

 

Step 3: Add a script task and go to script window and the following code.

Public Sub Main()

‘ Add your code here
‘ Statement to get connection string
MsgBox(Dts.Connections(“MyConnection”).ConnectionString)

Dts.TaskResult = ScriptResults.Success
End Sub

Step 4: execute the package

 

 

 

Thanks for reading.

About these ads

About Ayyappan Thangaraj

Technology is my passion.
This entry was posted in SSIS and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s