SSIS error at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)

Hi there,
Im using SSIS 2005 which using a script tasks creates a connection to our server and db and calls a variable to execute a SP. but I keep getting the following error at System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex)
0 rows returned

but I know if I run this query on its own straight from the db it will return rows.
I even added a data flow tasks to call the sp and export all rows to a test table, which it did and then moved to the script tasks but fails again.

now when I run the SP for some previous dates it runs fine.
I just don't know what it could be.
any help please?
thank you.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vikas GargAssociate Principal EngineerCommented:
What is your requirement ?
Why do you need to use a Script Task ?

May be
you are trying to read or loop through the rows from datatable. This error states that the datasource(DataTable) is not having any rows. To avoid this exception use this before you read or loop through datatable:
Hide   Copy Code

if(dt.Rows.Count  > 0 ){
     //Do your stuff here.
PutochAuthor Commented:
The script task does do a loop and checks what so is being called and runs the sp however I know that there is data there so I can't understand this error.
I saw had actually tried this suggestion earlier, perhaps I had placed if statement at the wrong area, It throw an error again.
PutochAuthor Commented:
also, using script task, (ive inherited this package) as the formatting seems to be setup inside of the script, and the output is put into xml format using a library.
when I added the if(dt.Rows.Count  > 0 ){

around my main script section which calls the SP
and then I closed your suggestion with
} end if

there is an underline error on the if statement then - am I missing something?
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

PutochAuthor Commented:
So the thing is if I run this script task for say the first 3 weeks of the last month, the package runs successfully, but when It runs for the whole month it causes this error.
I don't understand how it can see there is 0 rows returned when I know the frist 3 weeks when ranhave worked previously, could it be anything else other than this error its given me, could there be an index issue?
PutochAuthor Commented:
So because I knew there was information in the data set I was calling, I decided to go day by day to see was there one particular day that caused the error.
And so it looks like there was one row in the file for one day that had an issue with it.
and once I removed this row the script ran correctly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PutochAuthor Commented:
There had always been information in the dataset I was trying to access, so by checking to do a loop to ignore if there was no rows then skip wouldn't work as suggested. I had to find the row that caused the problem and remove it.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.