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


How to access the data connection string and assigning to a variable


How to access the data connection string and assigning to a variable

Author
Message
javieregh-756441
javieregh-756441
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
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
Attachments
screen.jpg (19 views, 126.00 KB)
jreece
jreece
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
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
javieregh-756441
javieregh-756441
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
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.
jreece
jreece
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
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.
jreece
jreece
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
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.
javieregh-756441
javieregh-756441
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 107
Thanks so much, now working fine
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