![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have my custom task - and inside my class code: public void Execute(object pPackage, object pPackageEvents, object pPackageLog, ref Microsoft.SQLServer.DTSPkg80.DTSTaskExecResult pTaskResult) { PackageLog packageLog = (PackageLog) pPackageLog; Package2 package = (Package2) pPackage; PackageEvents packageEvents = (PackageEvents) pPackageEvents; package.GlobalVariables.Remove("MyData"); package.GlobalVariables.AddGlobalVariable("MyData" , "simple string data"); And I run package which contains my custom task form C# code: object tmp = new object(); Microsoft.SQLServer.DTSPkg80.Package2 dtsp = new Microsoft.SQLServer.DTSPkg80.Package2(); dtsp.LoadFromSQLServer("(local)", "sa", "pwd", DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, "", null, null, "PPCustomTask",ref tmp ); dtsp.Execute(); dtsp.UnInitialize(); dtsp = null; Everything goes right, but after line "dtsp.Execute();" I want to read global variable "MyData" - code dtsp.GlobalVariables.Item("MyData").Value.ToString () fails: error: 'dtsp.GlobalVariables' does not exist. GlobalVariables collection contains no items... What is wrong? Pawel |
#3
| |||
| |||
|
|
In article <oprz77scgyy3yzc4 (AT) msnews (DOT) microsoft.com>, Mrozik mrozik.p (AT) interia (DOT) pl> writes I have my custom task - and inside my class code: public void Execute(object pPackage, object pPackageEvents, object pPackageLog, ref Microsoft.SQLServer.DTSPkg80.DTSTaskExecResult pTaskResult) { PackageLog packageLog = (PackageLog) pPackageLog; Package2 package = (Package2) pPackage; PackageEvents packageEvents = (PackageEvents) pPackageEvents; package.GlobalVariables.Remove("MyData"); package.GlobalVariables.AddGlobalVariable("MyData" , "simple string data"); And I run package which contains my custom task form C# code: object tmp = new object(); Microsoft.SQLServer.DTSPkg80.Package2 dtsp = new Microsoft.SQLServer.DTSPkg80.Package2(); dtsp.LoadFromSQLServer("(local)", "sa", "pwd", DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, "", null, null, "PPCustomTask",ref tmp ); dtsp.Execute(); dtsp.UnInitialize(); dtsp = null; Everything goes right, but after line "dtsp.Execute();" I want to read global variable "MyData" - code dtsp.GlobalVariables.Item("MyData").Value.ToString () fails: error: 'dtsp.GlobalVariables' does not exist. GlobalVariables collection contains no items... What is wrong? Pawel The code itself looks OK, although I didn't build the custom task. I get a different error though if my GV collection is empty or a I reference the wrong name, "An unhandled exception of type 'System.NullReferenceException' occurred in DtsExecuteCSharp.exe". This is using VS 2003. Can you do anything with the GlobalVariables collection e.g. |
#4
| |||
| |||
|
|
You are right - if I try line Debug.WriteLine(dtsp.GlobalVariables.Count.ToStrin g()); I have the same error. Before running dtsp.Execute(); I can remove/add global variables to collection, but after .Execute()m i can't read it - NullReferenceException occurs... Pawel |
#5
| |||
| |||
|
|
In article <oprz9j2h0qy3yzc4 (AT) msnews (DOT) microsoft.com>, Mrozik mrozik.p (AT) interia (DOT) pl> writes snip You are right - if I try line Debug.WriteLine(dtsp.GlobalVariables.Count.ToStrin g()); I have the same error. Before running dtsp.Execute(); I can remove/add global variables to collection, but after .Execute()m i can't read it - NullReferenceException occurs... Pawel Can you not even read the GlobalVariables collection Count property post Execute? |
#6
| |||
| |||
|
|
On Tue, 16 Dec 2003 18:41:29 +0000, Darren Green darren.green (AT) reply-to-newsgroup-only (DOT) uk.com> wrote: In article <oprz9j2h0qy3yzc4 (AT) msnews (DOT) microsoft.com>, Mrozik mrozik.p (AT) interia (DOT) pl> writes snip You are right - if I try line Debug.WriteLine(dtsp.GlobalVariables.Count.ToStrin g()); I have the same error. Before running dtsp.Execute(); I can remove/add global variables to collection, but after .Execute()m i can't read it - NullReferenceException occurs... Pawel Can you not even read the GlobalVariables collection Count property post Execute? After Execute I can not read any property from GlobalVariables collection... Pawel |

![]() |
| Thread Tools | |
| Display Modes | |
| |