SSIS - Error when passing object from one script task to another - ssis

I am passing object of a class from one script task to another. I have declared a package level variable by the name IPSService which is of type object.
The first script task contains the following piece of code
IPSService iPSService = new IPSService();
Dts.Variables["IPSService"].Value = iPSService;
I get an exception at the second line of code where the assignment happens.
The error message is as follows.
he element cannot be found in a collection. This error happens when you try to retrieve an element from a collection on a container during execution of the package and the element is not there.
Could somebody tell me what the issue is ?

You need to refer to the variable like this, notice the use of User:: in the variable name:
Dts.Variables["User::IPSService"].Value = iPSService;

Related

SSIS Setting OLE_DB Connection string from variable is not working getting error code dts_e_cannotacquireconnectionfromconnectionmanager

I have a parent child package situation where the parent is reading a SQL Server task table. Loops through the tasks and gets the connection string needed for the the task and passes it to the child package. I have created and set a variable in the parent package. I have also created and set a variable n the child package in a Script Task. The Variable is set to the Connection String of my OLE_DB connection in an expression (Package.DelayValidation = True). After the Script task runs(and works..I displayed a message box with the correct value) I run a Data Flow Task which trys to read the database using the connection string. This is where the "error code dts_e_cannotacquireconnectionfromconnectionmanager" happens. I know I have to be missing something, just can not put my finger on it.
Since both packages are available in a single project, try to select Project Reference ,in the parent package, as the ReferenceType and in the PackageNameFromProjectReference enter your child .

Google Script XML Cannot Call Method of Null

I have created a script which connects to an API. The script successfully parses the data and creates the required outputs. My script iterates through the record IDs to extract data for each record ID.
The existence of a child node does not exist for every parent. Thus where the parent has a child node my script operates perfectly.
var root2 = root[i].getChild('Assigned').getChildren('Staff');
However, when I encounter a parent ID where the child node does not exist I get this error. IE in the source data the client has not assigned staff to this record and thus the data node staff does not exist.
TypeError: Cannot call method "getChildren" of null.
How do I handle this error and ignore and let the code continue to run when this occurs? I have tried
if(root[i].getChild('Assigned').getChildren('Staff') != '') {
Code
}
But this still breaks the code and I get the error.
I think that the reason of the issue is that root[i].getChild('Assigned') is null, and in your script, even if Staff is not included in the parent (Assigned), no error occurs. In order to remove this issue, how about checking whether root[i] has the child of Assigned? Please try the following sample script.
Sample script:
if (root[i].getChildren().some(function(e) {return e.getName() == 'Assigned'})) {
// do something
}
In this script, it checks whether root[i] has the child of Assigned, and when the child is found, this if becomes true. So if root[i] doesn't have the child of Assigned, if becomes false, and do something is not run.
Note:
I prepared this script from the situation of your question. But I'm not sure about the actual XML data. So if this script was not what you want, can you provide the XML data or the sample data which can replicate your situation? By such sample data, I would like to modify this.
Reference:
getName()
Array.prototype.some()

SSIS- ADODB Recordset Error

I am getting below error while running my ssis package.
Error: COM error object information is available. Source: "ADODB.Recordset" error code: 0x800A0BCD Description: "Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.".
I am storing a value in an object variable using RecordSetDestination. And I am passing the object variable in 3 ForEachLoop containers and I am trying to run it parallel. If one of the container is passed then the rest of them getting failed.
Below is the same configuraiton in all 3 ForEachLoop's
Any property needs to change or object variable need to rest or we can't use the object variable for parallel exec in ForEach ADO Enumerator.
Need your input here... Thanks
The problem is the variable for the recordset.
The first option would be you add three data flows like origins pointing each one to a different variable.
The second is adding a multicast in your initial data flow, with three outputs, each one pointing to a different variable.
Then you go to each Foreach Loop Container and set the respective variable in the Enumerator configurarion section.
As Ferdipux proposed, try to run Foreach Loops sequentially. This worked for me.

Script error when function/sub parameter is 3 or more in Lotusscipt IBM Notes 9.0

I have a simple validation code in Lotusscript to check if an entry is already existing in a view. I use a function with 2 parameters passed ByVal, and is working fine.
But when I added a third parameter, it causes script error when called.
Here's a screenshot of the error I get when using 3 parameters in function call:
Here's function parameter setup:
I can use a workaround for the third parameter, but it makes no sense adding nested if's or select case inside the function, and will not make the function flexible for other modules.
How can I solve this?

SSIS Validate a Foreach File Enumerator

i have a ssis project, to start with, i have a Foreach File Enumerator and inside it are multiple tasks. It works flawlessly under normal circumstances, however if there is no file present in the enumerator directory, an error occurs, the question is, how can i make a validation or some sort for it to avoid it throwing an error on runtime? thanks
img links
ssis
http://s15.postimage.org/l41py15aj/ssis.png
error
http://s15.postimage.org/rj0qupc0b/ssiserror.png
You can have a script task before Foreach loop which basically checks for files and directory .Then have a precedence constraint to halt the package if either directory or files is not present .
Create 3 variables
Name DataType
Directory String
Files String
Exists int
In the script task just check if the directory is present along with the files .You can modify the code if you need to even enumerate the subfolders or check if specific files are present in the folder
if (Directory.Exists(Dts.Variables["User::Files"].Value.ToString()))
{
if (Directory.GetFiles(Dts.Variables["User::Files"].Value.ToString()).Length != 0)
{
Dts.Variables["User::Exists"].Value = 1;
}
else
{
Dts.Variables["User::Exists"].Value = 0;
}
}
else
{
Dts.Variables["User::Exists"].Value = 0;
}
In the precedence constraint check the value for the variable Exists
Evaluation operation : Expression
Expression : #Exists==1
Update :
In the script task editor you need to add the variables in the ReadOnlyVariable section in the script tag
I would set the expression on the Disable of the Sql Task assert whether the a file name was valid.
I haven't got SSIS here but I'll look it up.
You are aware of this particular case when the error occurs and you want to handle it. What if it fails for some other unforeseen error?
Always add an 'OnError' Event Handler.
Now, after handling your error condition using the event handler, you can choose to propogate this error to fail the task (which is the default behavior) or you can set the system variable, Propogate, in your 'OnError' event handler to false. This will allow the rest of the code after the For Each to continue as normal.