I'm trying to make a dynamic connection to DB for all of my packages. I'm trying to achieve this by loading my user defined variables with a Script Component .
I know I can also use environment variables to do this, the problem is that not all of my packages will be scheduled and some of them I run with a web service or a procedure, so I can't use a scheduled job to do this, and using the @reference_id is a bit complicate to maintain.
I have no idea how can I loop the variables. I tried
foreach (Variable var in Variables)
But that's not the way ..
So I have two questions here:
- How do I loop all the variables I passed?
- How do I get the Variable name out of it ? (I don't see a name attribute on Variables.VarName.?)
E.G. The OLE DB source will return two rows:
conName | conString
con1 | someConnection
con2 | someConnection
And I have two user defined variables in my project -> con1 and con2 . So, iterate through my varaibles -> foreach(variable) , if var.name = row.conName , load with row.conString value .