Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to access the data connection string and assigning to a variable Expand / Collapse
Author
Message
Posted Tuesday, October 20, 2009 10:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 19, 2010 6:02 PM
Points: 4, Visits: 107
When my ControlFlow is executed I need to read which value has my connection string for assigning to a global variable

Thanks a lot for you help

Javier


  Post Attachments 
screen.jpg (18 views, 126.93 KB)
Post #805898
Posted Tuesday, October 20, 2009 2:50 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, December 15, 2011 9:08 AM
Points: 34, Visits: 132
Use a script task. Include the variable you want to assign the connection string to on the ReadWriteVaribles property on the Script tab of the Script task Editor. In your script include a line like

varConnectionString = Dts.Connections.Item("your connection manager name").ConnectionString

The password is not saved in this connection string even if you have checked this option in the Connection Manager properties. You'll have to append it explicitly to your variable.
HTH
Post #806103
Posted Tuesday, October 20, 2009 3:18 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 19, 2010 6:02 PM
Points: 4, Visits: 107
I created the variable outside, public so when I create the Task Script in the field ReadWriteVariables I can see it and I pick it up.

Then in the Tab Script inside the Task Script I wrote the sentence you gave me

Public Sub Main()
varConnectionString as string

varConnectionString = Dts.Connections.Item("SQL_NCDW_Configuration").ConnectionString


But I received this error: Error at Script Task: The binary code for the script is not found. Please open the script in the designer by clicking Edit Script button and make sure it builds successfully.

Error at Script Task: There were errors during task validation.
Post #806125
Posted Tuesday, October 20, 2009 3:26 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, December 15, 2011 9:08 AM
Points: 34, Visits: 132
If you have followed the suggestion in the error message you posted and STILL are getting the error then you have a syntax or other error in your script preventing compilation and production of the binary code. Open your script and view the Error List. There should be some info there to help you resolve your error.
Post #806130
Posted Tuesday, October 20, 2009 3:30 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Thursday, December 15, 2011 9:08 AM
Points: 34, Visits: 132
oh I forgot to show you how to assign a value to an SSIS variable in code:

Dts.Variables("your SSIS variable").Value = varConnectionString

I'm no sure what you meant when you said you were using an outside, public variable.
Post #806133
Posted Tuesday, October 20, 2009 3:49 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, August 19, 2010 6:02 PM
Points: 4, Visits: 107
Thanks so much, now working fine
Post #806145
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse