Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Loop through connection manager


Loop through connection manager

Author
Message
s.hariharan16
s.hariharan16
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 111
I have a problem.

1. a table has conection string of various servers e.g

Record 1:

Server1

REcord 2:

Server 2

Record 3:

Server 3



2. In the SSIS pacakge i am trying to implement following:
Step1: Loop through the connection string of all the servers using for each loop and assign it to connection manager.
Step2: If any of the connection string is invalid or server not available the the package must evaluate that and execute the package for the next server.

In my case, server 2 connection string is invalid .
My requirement is the package shlud process for server 1 and server 3 and report error for server 2.


Following is the below code i have written in script task.

This code is "ConnMgr.AcquireConnection(Nothing)" is returning me true for server 2 connection which is invalid.

After debugging I found that its taking the connection string of server 1 which vaild.
Please suggest a solution for the same.

Public Class ScriptMain

' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables, events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.

Public Sub Main()
'
' Add your code here
'
Dim ConnMgr As ConnectionManager = Dts.Connections("hydhtc99600.acQuire_Chile")
Dim ConnStr As String = ConnMgr.ConnectionString
'Dts.Transaction()
'MsgBox(ConnStr)

Try
ConnMgr.AcquireConnection(Nothing)

Dts.Events.FireInformation(1, "", "Connection Successful", "", 0, False)
Dts.Events.FireInformation(2, "", "Connection String = " + ConnStr, "", 0, False)
ConnMgr.ReleaseConnection(Nothing)
Dts.TaskResult = Dts.Results.Success
Catch ex As Exception
Dts.Events.FireError(-1, "", "Connection Failed", "", 0)
Dts.Events.FireError(2, "", "Connection String = " + ConnStr, "", 0)
ConnMgr.ReleaseConnection(Nothing)
Dts.TaskResult = Dts.Results.Failure
End Try

End Sub

End Class


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search