.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Object Value lost in script component inside for loop container

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Sql Server
Hi All,

I need your expert advice here,

I have 5000 records to transform into csv file and due to the application limitation, the upload module to upload those 5000 records only can be done by batch of 100-200 record at one time.

Because of this, i try to use for loop to split the records into a few files e.g EE_1.csv, EE_2.csv.

The records was retrieved and saved into an object variable (ResultSet) before entering the For Loop flow

The issue i encounter, when it was on the 1st loop everything was fine, it is manage to generate X Records i specified but when it go for 2nd loop, the ResultSet is returning 0 Records..when the actual total records is 5000

Anyone can help this newbie what are the mistakes i made ?

The logic is something like

Public Overrides Sub CreateNewOutputRows()
oledbAdapter = New OleDb.OleDbDataAdapter
dataTable = New DataTable

oledbAdapter.Fill(dataTable, Me.Variables.resultset)
StartPoint = Me.Variables.FilesNumber 'To know which row to start
StartPoint = (StartPoint - 1) * Me.Variables.MaxRecord
EndPoint = (StartPoint + Me.Variables.MaxRecord) - 1

If dataTable.Rows.Count - 1 < EndPoint Then
EndPoint = dataTable.R

View Complete Post

More Related Resource Links

how to store the values in a object variable (package level scope) in a script component

I have declared a variable of object type with package level scope.  I want to assign values to this variable inside a script component.  My object should hold 5 columns in a row.  How to implement this ?

Sorting inside Script Component


Hi Guys,

A weird question, but i need to do a sorting inside of the Script Component. I have a RowNumber Column, that i need to sort by ascending.

Is their away to do this?



Passing Parameters to Execute SQL task which is inside a For Loop Container



I have a requirement.

In this I will get a value of 50 ids from one table.

I have an sp which will take ids as input parameter and insert values into another table.

My Problem is I am having a for loop container with me and inside that i have execute sql task in which I have stored procedure.

How can i map the id parameter to the execute sql task variable whichi is inside a forloop.




Thanks, A2H

CLR Inside Out: Large Object Heap Uncovered


This month CLR Inside Out reveals the secrets behind the Large Object Heap-what's there, when it's released, how the garbage collector handles the objects there.

Maoni Stephens

MSDN Magazine June 2008

CLR Inside Out: Managing Object Lifetime


Although the .NET Framework provides a managed execution environment, it is important to consider object lifetime management and write code that uses and releases resources correctly. The CLR team shows you how.

Tim Fischer

MSDN Magazine November 2007

Scripting: Windows Script Host 5.6 Boasts Windows XP Integration, Security, New Object Model


Windows Script Host (WSH) 5.6, a major upgrade for the WSH environment, provides some significant improvements over previous versions. A brand new security model that is tightly integrated with security in Windows XP allows administrators to place fine-grained restrictions on scripts reducing the risk from malicious code. In addition, local scripts can now run on remote machines, and enhancements to the object model reduce the amount of boilerplate code needed when writing professional code. This overview of WSH 5.6 explains these changes and how .NET and scripting work together.

Dino Esposito

MSDN Magazine May 2002

table inside tab container goes under the tab



my tab control going crazy

i have this code

and the intable button is under the tab and not inside. why? 


<asp1:TabContainer ID="Tabs"

Cannot access Label inside Repeater - "Object reference not set..."


I have a button on a page with a Repeater and an ObjectDataSource. To give credit where credit is due, the Repeater's paging functionality is courtesy of ScottGu. (However, I'm using ASP.NET 4.0 and SQL Server 2008, as opposed to ASP.NET 2.0 and SQL Server 2005.)

Anyway, in the button's click event, I need to access the Text property of a Label that's inside the Repeater because it's used as an input parameter in a stored procedure. I'm getting a NullReferenceException when trying to access the Label's Text property. I have researched this error and have tried a few different solutions (involving FindControl and the Repeater's ItemDataBound event), but I haven't been able to get it to work. Any suggestions, in VB or C#, would be greatly appreciated. The code is below.


<asp:Repeater ID="rptText" runat="server" DataSourceID="tbsDataSource">
<table width="100%" cellspacing="1">
<%-- some rows removed for brevity --%>

How to: Serialize Hashtable contained inside another object that is serialized as an array of object

Update:  I've added the entire program in a single block of C# text near the end of these posts that can be placed into a C# Program.cs file of a console project.   I have a class called MyHashtable that inherits from Hashtable and implements IXmlSerializable.  MyHashtable is contained inside another object called MyObject and I need to xml serialize an array of MyObject[].  Whenever I xml deserialize, the hashtable is deserialized, but only 1 of MyObjects from the MyObject[] array is deserialized.  The ReadXml uses "while (reader.NodeType != XmlNodeType.EndElement)" so I don't think the reader is consuming all of the xml internally.   Does anyone know why this is happening?  Thanks.    

Access the SQL Command Query Value Property from the OLEDB Container within a Script Task

Hello, I'd like to Access the SQL Command Query Value Property from the OLEDB Container within a Script Task so I can audit the queries which are executing. What is the syntax for this or does anyone have a sample on how to do this? Thank you

Script Component HELP!

Hi Guys, I have some recordset in the data flow. CURRENT Column1 Column2 Column3 Column4 Column5 Column6 Dine In DISCOUNT 20100824 121618 1859 37 Dine In TAX 20100824 121618 1859 -15.8 Dine In TOTAL 20100824 121618 1859 6.77 Dine In TENDER 20100824 121618 1859 63.2 Dine In TAX 20100824 121618 1859 63.2 Dine In DISCOUNT 20100824 121618 1860 37 Dine In TAX 20100824 121618 1860 -15.8 Dine In TOTAL 20100824 121618 1860 6.77 Dine In TENDER 20100824 121618 1860 63.2 Dine In TAX 20100824 121618 1860 63.2 I want to rename the second "TAX" in Column2 with the value of "DELIVERY CHARGE" and i was thinking on how to do this using script component. TARGET Column1 Column2 Column3 Column4 Column5 Column6 Dine In DISCOUNT 20100824 121618 1859 37 Dine In TAX 20100824 121618 1859 -15.8 Dine In TOTAL 20100824 121618 1859 6.77 Dine In TENDER 20100824 121618 1859 63.2 Dine In DELIVERY CHARGE 20100824 121618 1859 63.2 Dine In DISCOUNT 20100824 121618 1860 37 Dine In TAX 20100824 121618 1860 -15.8 Dine In TOTAL 20100824 121618 1860 6.77 Dine In TENDER 20100824 121618 1860 63.2 Dine In DELIVERY CHARGE 20100824 121618 1860 63.2 Thanks in advance,

Script Component

Hi Guys,   I am newbie and never done coding in vb. script, I am using SSIS component for this. I am using below code to allow user to enter storeid and change file name inside the directory from filename.ajk to storeid_filename.ajk.   Example:  01012010.ajk 02012010.ajk 03012010.ajk Once the user enter the storeid all the files in that particular directory will change to like this automatically 192572_01012010.ajk 192572_02012010.ajk 192572_03012010.ajk Now all I want is to change the file name from 01012010 to 20100101. So once the user enter the storeid it has to change it to  192572_20100101.ajk 192572_201001012.ajk 192572_20100103.ajk     Please help me guys its a urgent help.       Public Sub Main() ' ' Add your code here         '         Dim InputFilePath As String         Dim StoreNo As String = InputBox("Enter Store No", "StoreNo")         InputFilePath = Dts.Variables("strInputFolder").Value         Dim strFileSize As String = ""           Dts.Variables("StoreNo").Value = StoreNo         Dim di As New IO.DirectoryInfo(InputFilePath)         Dim aryFi As IO.FileInfo

ForEach Loop Container Configuration Question

So here is my question/situation. I have a table that contains a list of all of our servers/instances for my organization. I have a script that I'd like to execute against all of the servers in that list and I was thinking that I should be able to use this container to pull the name/instance from the table, execute the script, store the results in a local table. However, I'm not quite sure on how to attack this meaning not sure which configuration that I would need to use to get me going down the right direction. I've looked around and found alot of documentation on how to enumerate multiple files and folders, but nothing really for what I'm trying to do. Any help or direction would be greatly appreciated.Big Ern

Question using Script Component

Hi Guys, I have this records on my dataflow.   Column1 Column2 Column3 ITEM 1 P ITEM 2 S ITEM 3 N ITEM 4 O ITEM 5 M ITEM 6 MC ITEM 7 MAO ITEM 8 MT ITEM 9 P ITEM 10 S ITEM 11 N ITEM 12 O ITEM 13 M ITEM 14 MC ITEM 15 MAO ITEM 16 MT    I want to add a new column that based on these condition. 1. If Column1 and Column3 is "S", "N", "O", "P" then Column4 value is  1 2. If Column1 and Column3 is "M" then Column4 values is 0 3. if Column1 is not "ITEM" then Column4 value is NULL 4. If Column1 and Column3 is "MC", "MAO" , "MT" then get the last column2 value place for Column4.  Column1 Column2 Column3 Column4 ITEM 1 P 1 ITEM 2 S 1 ITEM 3 N 1 ITEM 4 O 1 ITEM 5 M 5 ITEM 6 MC 5 ITEM 7 MAO 5 ITEM 8 MT 5 ITEM 9 P 1 ITEM 10 S 1 ITEM 11 N 1 ITEM 12 M 12 ITEM 13 O 1 ITEM 14 MC 1 ITEM 15 MAO 1 ITEM 16 MT 1  I have the following script to get some of the conditions, but im stuck in the last one with the "MC, MAO, MT" in Column3.  If Column1 = "ITEM" And Column3 = "S" Or Column3 = "N" Or Column3 = "O" Or Column3 = "P" Then             Column4 = "1" &

SSIS 2005 - Foreach loop container - Stopping the loop after processing X number of file?

I need to stop the Foreach loop container from processing more files in the folder than desired. Scenario:  If I only want 1 files processed, i need to stop the loop after it finds 1 file.  No matter what the contraints or tests or variables I set, the loop processes all the files in the folder.  This is bad because I need the value of the 1st mapped variable and not the last one it finds. I have tried counting records and setting variables used in the contraints but to no avail  Nothing seems to stop the loop. Please advise

How to go to next iteration of ForEach Loop container on task failure

I'm using a ForEach Loop container to iterate through a set of files and import/validate the data.  Within each loop, the first thing that happens is that I fill a variable from a table and then use a script task to make sure that the rest of the package should be run for this particular file.  If it should continue, I set Dts.TaskResult = Dts.Results.Success, and if it shouldn't, I set it to Dts.Results.Failure.  My question is, how do I get it to exit the current iteration of the loop and continue to the next iteration?  The way it is now, the package just stops completely.  I set the FailPackageOnFailure property to False for the script task, but that doesn't make a difference.  I also tried pointing a failure precedence contstraint bacl to the loop container, but that's not allowed.  How can I make it just continue in the loop?   Thanks.

Using Foreach loop Container in SSIS 2005 package and scheduling the package using SQL job on 64-bit

I've an SSIS package 2005 which uses a for each loop container, this package runs fine when I run it on the local machine . My server is 64 bit SQL 2005 and I 've successfully deployed my package on the server both to the File system and SQL server. I've also set Run64bitruntime to false in my pacakge. Now I need schedule the package using SQL job. Since Microsoft Jet Provider 4.0 is not available for 64 bit, I had to write script to schedule the package. Here is my script. declare   @ssisstr varchar(8000) declare @returncode int set   @ssisstr = 'dtexec /sq Package1 /DE 123' EXEC   @returncode = xp_cmdshell @ssisstr select   @returncode I'm getting the following error when I execute the job. Could not load package "Package1" because of error 0xC0010014. Description: One or more error occurred. There should be more specific errors preceding this one that explains the details of the errors. This message is used as a return value from functions that encounter errors. I'm getting the same error if I run this from commandline. Any help would be really appreciated. Thanks in advance. PARC
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend