Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / Services / Integration Services / July 2008

Tip: Looking for answers? Try searching our database.

Reading System Variables in the Script Task

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
fastthinker - 28 Jul 2008 19:57 GMT
Hello,

I have an SSIS VB.NET Script Task that is a starting task in an SSIS
package. Since the package could be executed either independently, or
as a step/task of a bigger package, VB.NET script needs to read the
name of the package. I tried to reference the system variable in 2
ways:

1) ... = CStr(Dts.Variables("System::PackageName").Value
2) ... = CStr(Dts.Variables("PackageName").Value)

I tried to include it into the list of Read-Only Variables of the
Task, or do without it.
It did not help me with running the package in the Debug mode from VS
2005.

Then, I created a user variable: User::gvExprPN, and I set the
property "EvaluateAsExpression" equal to True, and I set expression
equal to @[System :: PackageName]. I added the variable User::gvExprPN
to the list of Read-Write variables of the VB.NET Script Task. Still,
when I launch the package from VS 2005, I am getting a message stating
that it is not possible to lock some Read-Write variables.

How could I retrieve the value of System::PackageName variable in
VB.NET Script task?
What do I miss in this User Variable / Expression setup?

Thanks in advance.

Alex
matteus - 29 Jul 2008 10:26 GMT
> Hello,

Hi Alex,

> I have an SSIS VB.NET Script Task that is a starting task in an SSIS
> package. Since the package could be executed either independently, or
[quoted text clipped - 4 lines]
> 1) ... = CStr(Dts.Variables("System::PackageName").Value
> 2) ... = CStr(Dts.Variables("PackageName").Value)

Actually it seems as you the correct code to retrieve the value...
apart a parenthesys missing in the first one

> I tried to include it into the list of Read-Only Variables of the
> Task, or do without it.
[quoted text clipped - 11 lines]
> VB.NET Script task?
> What do I miss in this User Variable / Expression setup?

I created a package with a single task: Script Task. In its properties
I set "PackageName" in the ReadOnlyVariables property (it worked for
ReadWriteVariables as well).
And this is the code I added in the Main() subroutine:
MsgBox(CStr(Dts.Variables("System::PackageName").Value))
I tested without the part "System::" and it worked too.

Well really I don't understand why you could get the error but check
it out...

> Thanks in advance.
>
> Alex

You're welcome ;)
HTH
M.
fastthinker - 29 Jul 2008 19:01 GMT
> On 28 Lug, 20:57, fastthinker <quickerm...@gmail.com> wrote:> Hello,
>
[quoted text clipped - 47 lines]
>
> - Show quoted text -

Well, I solved my prolem with the help of VariableDispenser and
dynamic system/user variable locking.

Matteus, thanks for your help suggestions.

Alex
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.