.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

Foreach File Enumerator - Use Variable to Set FileSpec Property

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :Sql Server
Hello All: Can anyone give guidance on how to set the mask for a Foreach File Enumerator programmatically? I have a DB that has a list of masks. I am retrieving that into an ADO recordset. For each record I retrieve the value into a variable. I would like to look at a directory and move all files that begin with the chars for each item in my recordset variable. TIA - Tom

View Complete Post

More Related Resource Links

Dealing with a changing folder value in Foreach File Enumerator

I have a Foreach Loop component that loops through files in a folder.  That folder doesn't exist on the server where I'm going to move the package to.  Within the Foreach Loop Editor, the Enumerator Configuration Folder doesn't appear to be able to take a variable value.  Also, it doesn't appear that there's a "Folder" property in the expressions property list. Is there some way I can use a variable value for this foreach file loop's folder location?  I need to move the package to the dev server and then eventually to the prod server.  I don't mind manually opening the *.dtsx file on each server to change the values accordingly, but I would think there's a better way. Any advice you could offer would be greatly appreciated.  The dev and prod servers have SQL Server 2008 R2 with SSIS 2008 R2 on Windows 2008 Server. Thanks, everybody.

Missing "Foreach File Enumerator and Foreach Item Enumerator"


Ever since installing SQL Server 2005 SP1, when using the Foreach Loop
container in SSIS the Foreach File Enumerator and Foreach Item Enumerator are
missing from the Enumerator drop down box.  Anyone else seen this issue?  and
know how to fix it?




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

Foreach Loop Container.ForEachEnumerator.Properties[FileSpec] Exception -This occurs when an attempt

I run into the following 2 exceptions when I execute a package on SQL Server 2005 64 bit machine. The package fails when SQL Server version is 9.0.3310 which is a production box. I have tested it on 3 others development boxes with SQL version 9.0.1399, 9.0.3315 & 9.0.4053 and the package executes fine. I am unable to make a determination if this issue is related to SQL versions or a bug in the package design. I would like to understand the exception better before I request an SP3 & patches installed to upgrade it to version 9.0.4053 on the production box. I have scheduled jobs to run these packages and we are trying to locate Excel files on a drive using For Each Loop Enumerator. The packages are configured to use configuration files. Please note the destination directory does have the Excel files we are looking for. Source: Well_Test_Package Description: The package path referenced an object that cannot be found: "\Package\Daily Alloc Spread Sheet Foreach Loop Container.ForEachEnumerator.Properties[Directory]". This occurs when an attempt is made to resolve a package path to an object that cannot be found.  End Warning  Warning: 2010-08-31 00:41:13.66     Code: 0x80012017     Source: Well_Test_Package      Description: The package path referenced an object that ca

Could not set a datasource to Schema Rowset Enumerator in Foreach Loop Container



Everytime I want set a datasource (also if I create a new one with an click on the drop down) I got the following error message from the container.


TITLE: For each schema rowset

The new connection, LocalHost.ReportServer, is not an OLE DB connection so it can not be used by the schema rowset enumerator and, therefore, will not be added to the connections list.

But if I generate a OLE DB connection manually it does not appear in the dropdown list of the container. Does anybody know what I have to do in that case?

Thanks, Nils

how to change button backcolor property on a form from a class file


Hello friends,

I am having a problem of updating the main form button backcolor property from another class. I have attahced the code. Please tell how can i rectify this problem.

PopUp is another class, in which i want that when ToolStripDropDown closes it change the form button BackColor from Orange to WhiteSmoke.


public partial class PopUp : ToolStripDropDown


        public PopUp()





        protected override void OnClosed(ToolStripDropDownClosedEventArgs e)


               Form1 f1 = new Form1();

              // f1._pushed = false;

       f1.Controls["button1"].BackColor = Color.WhiteSmoke;





It seems that this line works, i checked it using MessageBox it changes the backcolor property but it does not updated to the form displayed on the screen. 

Can anyone help me

Foreach variable scope and memoray allocation - Which is Better ?


Can any one help to to understand the perfomace difference between the code snippet 1 and 2, if any ?
Which way is better ? When will the product object eligible of being garbage collected in both the cases?
Snippet 1

pubic List<Product> GetProductDetails()
  List<Product> pList = new List<Product>(); 

  foreach(Category aCategory in Categories)
       Product aProduct = new Product( aCategoty.Name);  
  return list  ;

Snippet 2
pubic List<Product> GetProductDetails()
  List<Product> pList = new List<Product>(); 

  Product aProduct = null;  
  foreach(Category aCategory in Categories)
     aProduct = new Product( aCategoty.Name);  
  return list  ;



Accessing static variable in global.ashx file


Hi All ,

I want to access the static variable in my global.ashx file  I am using classname.variable name for accessing the variable but the variable name dose not appear.Can someone tell me how to access static varialbe in *.ashx file.

property setting in report server (2008) config file is not working as expected.



I have set the <WorkingSetMinimum> property to 2.4GB in my reportserver 2008 config file.

By defintion, <WorkingSetMinimum> setting means,

  1. Lower limit of service memory consumption; memory will not be released if the consumption is below this amount, though the service will not reserve the designated amount of memory when it starts.
  2. If service uses more than the designated amout of memory, it will release back the memory only till this declared value and not beyond that, which means it should keep 2.4GB as designated.

See this link for definition: http://books.google.com/books?id=mzY_Xo_9J-gC&pg=PA589&lpg=PA589&dq=What+is+%3Cworkingsetminimum%3E+in+report+server+configuration+file&source=bl&ots=r_xhRp8erj&sig=E_o0-Dh2SXOgMNrW3sptt5oZrYI&hl=en&ei=f5mjTNeNM5O8ccmErJMI&sa=X&oi=book_result&ct=result&resnum=4&ved=0CCAQ6AEwAw#

How can i access claaes Property values in xml file ?



actually i am creating sitemap.sitemap is actually an xml file.And i have stored each page's url  of my project as Public shared property of a class.Now while creating sitemap xml file i want to get access to those property on my class, so that url should not be hardcoded.How can i do that ?

Please help .

how to insert a path file into an array and listview using openfiledialog with multiselect property?



i have problem to insert path file into an array and listview(detail) using open file dialog wit multiselect property, please give me sample to make it?

Add image to ImageList and set File Name as Tag property


I'd like to create a thumbnail viewer to view all .jpg files within a folder.

So i create thumbnails and add them to a ImageList.

          Image img1 = Image.FromFile(fi.FullName);
          img1.Tag = fi.Name;
          imageList.Images.Add(getThumbnaiImage(imageList.ImageSize.Width, img1));

then add them to my ListView.

      for (int j = 0; j < imageList.Images.Count; j++)
        this.listView1.Items.Add("Image\n" + j);
        this.listView1.Items[j].ImageIndex = j;

Instead of the 'description' "Image\n" + j, i'd like to use the Tag property which should contain the file name.
doesn't work.

Error: System.NullReferenceException was unhandled.

How can i show the thumbnails in the ListView with the real file names ?

I don't know how to capture the variable value which is currently being used within the foreach loo


I have created a foreach loop similar to that in http://www.codeproject.com/KB/database/foreachadossis.aspx.

The variable which the foreach loop uses is an object data type.

I don't know how to capture the variable value which is currently being used within the foreach loop.

Does anybody have any tips?

Mr Shaw

ADO enumerator AND Variable enumerator



when will we go for ADO enumerator AND Variable enumerator in or for each loop.

can u explain clearly

Loading XML File into some XML Variable Using SSIS 2005



I have one xml file in some share network drive which I want to load.

I can load the XML file into XML Source. But Can I save that XML data into some XML variable that I can pass into a stored procedure? if Yes How Can I save the XML into a XML variable in SSIS.

If the above is not possible, I was thinking to pass the XML File path to the stored procedure and from with in the SP I will use "SELECT * FROM OPEROWSET (BULK..." to load the XML into variable and process.

Please advice which method I should opt here if I look into performance and multiuser case?


Access property of object as session variable as declarative datasource parameter value


I am storing a custom "Organisation" object as a session variable. One of the properties of  the Organisation object is "OrganisationID" (integer).

I have a DataSource that requires a parameter value to run, and I want to use a SessionParameter to populate this. In a previous version, I stored the OrganisationID directly as a session variable. In that case, I could easily access it like this:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    SelectCommand="spGetUserJobList" SelectCommandType="StoredProcedure">
        <asp:SessionParameter Name="OrganisationID" SessionField="OrganisationID" Type="Int32" />

However, how do I now access the OrganisationID property of an "Organisation" type session variable (called "Organisation")?

 I have tried this, which does not seem to work:

<asp:SessionParameter Name="OrganisationID" SessionField="Organisation.OrganisationID" Type="Int32" />


foreach loop - delete file task


i have ado enumerator on foreach loop and one of the variable contains the file name. following are the task which get executed in for each loop but i'm getting error on delete file task

1. Run a script to create pdf file from ssrs (using filename and path in ado enumerator). Working great.

2. Send email with attached of above pdf file (working great)

3. Now in 3rd step, i want to delete the file, so used file system task and delete file . i'm getting following error

[File System Task] Error: An error occurred with the following error message: "The process cannot access the file 'p:\information technology\report output to send\eft\0000023744-EF_DEN1_10-29-10_EFT.pdf' because it is being used by another process.".

I'm not sure what is using the file that it is not letting me delete the file.

Any clue?

mark it as answer if it answered your question :)
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