• RELEVANCY SCORE 3.56

    DB:3.56:Unusual Behavior With Threads Created Inside Foreach Loop sx





    I am having some weird behavior when creating threads inside a foreach loop. Not my real code, but the essentials of what I am doing:

    DataSet1:
    Row0,Col0 = A
    Row1,Col0 = B
    Row2,Col0 = C

    // this is inside the first class
    foreach (DataRow row in DataSet.Tables[0].Rows)
    {
    try
    {
    Thread T = new Thread(()= new TestClass(row));
    T.Start();
    }
    catch (Exception E1)
    {
    Textbox.Text = e;
    }
    }

    // Later on after above class is complete, another class
    public class TestClass
    {
    public TestClass(DataRow theRow)
    {
    Messagebox.Show(theRow[0].ToString());
    }
    }

    The weird thing that is happening.... I can run this 10 times. ~8 times it will be fine and show A B C, but ~2 out of 10 times it will repeat, like A A B.

    How can my foreach(row indataset) loop create 2 threads and pass in the same exact row? It's either failing to increment during the loop, or something with threading is acting crazy. Any help is appreciated. Oh yea, I am not getting any exceptions
    during the foreach andthread creation - so, I am assuming the try/catch isn't causing it.

    DB:3.56:Unusual Behavior With Threads Created Inside Foreach Loop sx

    Hi, Visual studio is not so smart and after complie, it will change your code to this:
    IEnumerator enumerator = DataSet.Tables[0].Rows.GetEnumerator();
    DataRow row;
    while (enumerator.MoveNext())
    {
    row = (DataRow)enumerator.Current;
    try
    {
    Thread T = new Thread(() = new TestClass(row));
    T.Start();
    }
    catch (Exception E1_C2)
    { Textbox.Text = e; }
    }
    From above code, you can know why you see something like A,A,B.
    if you want to see the correct result, try this minor change to your code:
    foreach (DataRow row in DataSet.Tables[0].Rows)

    {

    DataRow tmp = row;

    try

    {

    Thread T = new Thread(()= new TestClass(tmp));

    T.Start();

    }

    catch (Exception E1)

    {

    Textbox.Text = e;

    }

    }

  • RELEVANCY SCORE 2.76

    DB:2.76:Foreach Parallel In Bpel 2.0 pp





    According with some sites:Introduction of BPEL 2.0 forEach activity amp;#8211; valuable loop and standard based successor to FlowNlt;/titlegtUsing Parallel Flow in a BPEL Process - 11g Release 1 (11.1.1.6.3)The parallelism in BPEL 2.0 (ForEach) perform in a single thread.I have a scenario where i have a synchronous call inside a ForEach and I want to perform in multiple threads. That is possible?

    DB:2.76:Foreach Parallel In Bpel 2.0 pp

    Have a look on documentation about the nonBlockingInvoke:Using Parallel Flow in a BPEL Process - 11g Release 1 (11.1.1.6.3) "To achieve pseudo-parallelism, you can configure invoke activities to be nonblocking with the nonBlockingInvoke deployment descriptor property. When this property is set to true, the process manager creates a new thread to perform each branch's invoke activity in parallel."But if you need really parallelism, go to OSB and use split-join.

  • RELEVANCY SCORE 2.68

    DB:2.68:Enumerate Contents Of File List Variable s9





    Sql 2008. I created a Foreach Loop with a File System Task inside to capture a list of all filenames in a directoryinto a variable. How can I actually enumerate the names in the variable(collection) from SSIS? (I tried using a VB
    script task with a MsgBoxbut could not make it work.)

    TIA,
    Barkingdog

    DB:2.68:Enumerate Contents Of File List Variable s9

    If you want to use variable to store file names, you can define a package variable (Object Type) to save file names.

    Then define another package variable (String type) to get value from Object in a loop.
    Please refer to my blog -
    http://simonlv.blogspot.com/2012/06/ssis-step-by-step-003-sync-document.html there's an example to loop file names with Object type.
    You also can use Foreach File Enumerator, just follow Reza Raad's suggestion.

    Please vote if it's helpful and mark it as an answer!

  • RELEVANCY SCORE 2.67

    DB:2.67:Is It Possible To Control Which Iteration A Foreach Loop Should Execute? s1



    I'm using the example "SequenceFilePostStepFailure" so that the user can decide what to do when a step failes. If you choose "retry", the program returns and reruns a VI inside a ForEach loop. The problem is that the ForEach loop loads the VI with the next setof parameters.

    Is there a way to control this? I would like the ForEach loop to not increment when the user wants to retry the step. It seems to me that the whole loop is considered 1 step, and that it is incremented because the whole loop is re run.

    I was told that this is not the case if it's an error instead of a failure,and the user presses "retry".

    Thanks

    DB:2.67:Is It Possible To Control Which Iteration A Foreach Loop Should Execute? s1


    Never mind, i figuered it out. "RunState.Caller" were setting values in the wrong sequence.

  • RELEVANCY SCORE 2.57

    DB:2.57:List .Find Method Inside The Foreach Loop 9p


    any fault using List.Find method using inside the foreach loop here my code
    foreach (Bookingspan alreadycheckeditem in lstBooking)
    {
    GetBookingResult
    bookspan = stafflist.Find(delegate(GetBookingResult booksp)
    {
    return booksp.ID == alreadycheckeditem.ID;
    });
    if (bookspan != null)
    {
    if (stafflist.Contains(bookspan))
    {
    stafflist.Remove(bookspan);
    }
    }
    }
    bookspan value is always null . i don't know this error
    . please help
    rageshS

    DB:2.57:List .Find Method Inside The Foreach Loop 9p


    Hello rageshS,

    Welcome the MSDN forum.

    I am using the following code snippet for testing, and I want to find if its the Find() method issue. But my test result tells
    me it works well.

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace ConsoleApplication11
    {
    class Program
    {
    static void Main(string[] args)
    {
    Listtest l = new Listtest();
    l.Add(new test());
    l.Add(new test());
    l.Add(new test());
    test t = l.Find(
    delegate(test te)
    {
    return te.show() == true;
    });
    if (t != null)
    {
    Console.WriteLine(t.show());
    }
    Console.Read();
    }
    }
    class test
    {
    public test()
    {
    // show();
    }
    public string show()
    {
    Console.WriteLine(nice to meet you.);
    return true;
    }
    }
    }

  • RELEVANCY SCORE 2.53

    DB:2.53:Ssis Foreach Loop Container - Grabbing The Latest Text File Base By Date And Time. 81


    How can you AUTOMATE OR Loop a directory containing text files using Foreach Loop Container one by one without inserting all text files TO THE DISTINATION. I HAVE A SCRIPT FILE THAT GET FILELIST CONNECTED TO FOREACH LOOP CONTAINER THAT LOOPS
    THE DIRECTORY USING INDEXING FILENAME = 0 THEN A DATA FLOW inside which i have flat file that formats the fixed with then dumping it in sql table using oldb connection. So every time i execute it it grabs the files from the beginning and dumps all test files
    to the destination. Is there batch file that i can write to get the latest text file instead of all the files in the directory.

    DB:2.53:Ssis Foreach Loop Container - Grabbing The Latest Text File Base By Date And Time. 81

    Thank you all for your insights and had work this thread has really helped me a lot.

  • RELEVANCY SCORE 2.53

    DB:2.53:Problem With Bitmapimage Progress Event ak


    The BitmapImage Progress event fails to call inside a foreach loop.Actually i m trying to download some images from remote url.
    inside the loop i m calling the BitmapImage progress event to do some additional work.But that event never fires inside a for loop
    If i call it once by declaring an image element it design time.Then it works.

    DB:2.53:Problem With Bitmapimage Progress Event ak

    I want to get the actual height and width of an image inside that event but inside a loop the event is not working

  • RELEVANCY SCORE 2.53

    DB:2.53:Data Flow Inside Of Foreach Loop With Variable xm


    Hello,
     
    I have a data flow task inside of a ForEach loop.  I'm trying to use SQL command from variable for Data access mode in OLE DB Source Editor.  But I'm getting incorrect syntax error: Incorrect syntax near '='. 
    Here's the expression in the variable:
     
    select ID, CatalogID, SourceID,FirstName, LastName, Address1, Address2, City, State, Zip, Phone,Fax from dbo.catalog where catalogid = + @[User:trCatalog]
     
    The scope of this variable is Foreach loop container.  When I click Evaluate Expression, I get the value in the box with no error.  I also validated the User:trCatalog variable by using Script Task to show the value in a MsgBox. 
     
    Can someone point me where I need to check?
     
    Thanks!!

    DB:2.53:Data Flow Inside Of Foreach Loop With Variable xm

    Thanks for the prompt response.  I will look into the link that you provided me.
    However, I see a lot of people using the SQL statement variable in an expression that uses another variable. 
    For example, I copied this from another thread.  This example is very similar to my case...
     
    1) Add a StoreCode variable to your package
    2) Add a ForEach Loop container to your control flow, looping over the available store codes
    3) Store the current storecode from the Foreach loop in the StoreCode variable
    4) Add a SqlSelectStatement variable to your package
    5) Edit the SqlSelectStatement variable so that it is based on an expression that uses the StoreCode variable to only SELECT the records you need
    6) Update the OLE DB source component in your data flow to use the SqlSelectStatement variable as its source

  • RELEVANCY SCORE 2.51

    DB:2.51:Problem With Multi Threads And Sql Server - Timeout xp


    I've created a console application that purge some log table (~11). and my application use Parallel.foreach to loop and create some threads.
    The flow is something like this:

    - Loop creating threads
    - Inside one thread
    1 Purge table (~200000 registers)
    2 Save log
    3 If have more registers to purge go back to step 1 (recursive)
    - Save general log

    All tables have to purge ~3000000 registers.

    The problem is in some cases we got a timeout but not in all tables.
    I tested without creating threads and it works.
    Whats the problem with threads and sql server?

    The LDF file is locking something?
    The database cant do this purge with threads?!

    Thanks

    DB:2.51:Problem With Multi Threads And Sql Server - Timeout xp

    No, i not delete all rows.
    One table have ~35.000.000 but i only delete rows who have 91 days or more.

    first i get de max id (best way i guess. i think is better do it than put the where clause with date directly in delete command, cause the date dosen't have a index)
    SELECT MAX([PKColumn]) FROM [TableName] WITH(NOLOCK) WHERE [DateColumn] = @Data

    Then i delete directly with the clustered index.
    DELETE TOP (200000) FROM [TableName] WHERE [PKColumn] = [ID]

    I ask if it executed 200000, if is true then i call the delete again, if execute fewer than 200000 the thread is done.
    Sounds like you have to scan some big tables to get the max, that doesn't explain blocking but it does explain contention.
    Probably easiest just to do them one at a time. The lack of contention will make that very nearly as fast as doing them all together. Could even run faster sequentially.
    But better yet, have you looked at partitioned tables? They are made for exactly this scenario. Your delete time would drop to very nearly zero, it becomes a DDL operation instead of DML.
    Josh

  • RELEVANCY SCORE 2.50

    DB:2.50:Timed Loop Bug 9c


    I got a bug inside a timed loop! I modified a array and after a while there will be created some zeros inside the array! I attached a VI containing example code!
    The array seems to be ok, if I replace the timed loop with a while loop!

    DB:2.50:Timed Loop Bug 9c


    The 'search array' is only to detect the zeros! (Thats the reason for internal for loop and the breakpoint) It means, the VI stops automatically, if a zero is detected! I used the code of the for loop inside a custom probe on different parts of the graph array and I got the zeros sometimes on X and sometimes on Y component. Sometimes the array what comes out of the shift register was different to that what comes in. In the case of the example VI i got Zeros on an other Index as I replaced in 'replace array subset'......I tested it once again and I got zeros at an array size of 20828, but thats differential! In the screen shot you can see, that the date of plot six 01/01/1904 therefore..










    Attachments:







    Bug1.png ‏77 KB

  • RELEVANCY SCORE 2.49

    DB:2.49:Threads Or Runtime.Exec To Run Numerous Processes Simultaneously jz


    Hello,

    I am trying to determine the best way to do this, and hopefully get some code examples, because I am a novice with these commands.

    I have a program called master.java which has a loop, and inside the loop other programs or processes will be started which run simultaneously, something like this:

    ------------------------Master.java------------------------

    import java.sql.*;
    import other stuff...

    public class Master {

    public static void main(String args []) throws SQLException, IOException {

    //connection pool created here

    while (true) { // start loop here (each loop takes about five minutes)

    // set values of variables

    // select a slave process to run (from a list of slave programs)
    Thread.execute selected slave program (or runtime.exec?)

    // check for loop exit value

    } // end while loop

    System.out.println("Program Complete");

    } catch (Exception e) {
    System.out.println("Error: " + e);
    } finally {
    if (rSet1 != null)
    try { rSet1.close(); } catch( SQLException ignore ) { /* ignored */ }
    connection.close();
    }
    }
    }

    -------end Master.java--------------------------------------------------------

    This master.java program will run continuously for days or weeks, each time through the loop starting another slave process which runs for five minutes to up to an hour, which means there may be ten to twenty of these slave processes running simultaneously.

    I believe threads is the best way to do this, but I don't know where to locate these slave programs: either inside the master.java program or separate slave.java files?

    Thanks again,
    Logan

    DB:2.49:Threads Or Runtime.Exec To Run Numerous Processes Simultaneously jz

    Once you have the overheads of running a JVM there's no point in running a second without good reason.

    What you're talking about is a "service", a program that runs all the time in the background. Check out jakarta.apache.org/commons for the daemon package.

    In java many source files will normally be used to create one application, cooperating under the JVM so the question of what goes in what source file is not greatly significant.

    As you've sketched the program out the master isn't waiting but creating new slave threads as quickly as possible. You'd soon run out of resources. The master loop clearly needs to do some waiting. What triggers it's creation of a new "slave"?

    To run a thread you create an object of a class implementing Runnable, create a Thread object on that object, then call start() on the Thread object.

    Basically something like this:

    class Slave implements Runnable {
    ...

    public void run() {
    // do the thread's processing here
    }
    }
    ....
    // inside your master loop
    Thread slaveThread = new Thread(new Slave());
    slaveThread.start();

  • RELEVANCY SCORE 2.49

    DB:2.49:Can't Exit Of A Loop pp



    Hi, there a few things I don't understand

    I have a loop that execute threads.

    int threads;
    int i=0;
    threads = n;
    while (threads 0) {

    if (i n) {

    i++;

    new MyThread(this,i).start();
    // MyThread does some database operation
    // when MyThread finishes
    // threads is decreased by one (threads--)

    }
    }

    My problem is thatt when threads goes to 0 I can't exit out of the while loop.
    If I put some code that prints something inside the loop.
    I am able to get out of the loop.

    What is wrong with my code?

    Thanks.

    C.

    DB:2.49:Can't Exit Of A Loop pp

    There is nothing wrong it works fine.

    public class loop {
    public static void main(String[] args)
    {
    int threads;
    int i=0;
    threads = 5;
    while (threads 0)
    {
    if (i 5)
    {
    i++;
    System.out.println(i)
    } threads-=threads;
    } }}

  • RELEVANCY SCORE 2.49

    DB:2.49:Combobox Value Member Foreach Loop pj


    How to build a combobox with a combobox ValueMember in a foreach loop ?

    DB:2.49:Combobox Value Member Foreach Loop pj

    You need to modify you class definition to not be read only like this:
     
        public class MyColor    {        private string shortName;        private string fullName;
            public MyColor(string strFullName, string strShortName)        {            this.shortName = strShortName;            this.fullName = strFullName;        }
            public string ShortName        {
                set { shortName = value; }            get { return shortName; }        }
            public string FullName        {
                set { fullName = value; }            get { return fullName; }        }    }
     

  • RELEVANCY SCORE 2.49

    DB:2.49:Is Having A Break In A Foreach Loop That Is Itself Inside A For Loop Breaking Both Loops? f1



    Just to post a clear answer to the question: no ;)


    Breaking within a loop will break only the exact loop you're in, without considering its parents.

    DB:2.49:Is Having A Break In A Foreach Loop That Is Itself Inside A For Loop Breaking Both Loops? f1


    To answer your question: No, there is nothing wrong with the break statement.


    But your code logic looks a bit weird. Try to make a dedicated method instead of series of if... else. Something like:

    public enum Animal { Crab, Turtle, Jelly }

    // ...

    void MainMethod(Vector3 playerPosition)
    {
    crabHere = CheckAnimal(Animal.Crab, playerPosition);
    turtleHere = CheckAnimal(Animal.Turtle, playerPosition);
    jellyHere = CheckAnimal(Animal.Jelly, playerPosition);
    }

    bool CheckAnimal(Animal animal, Vector3 playerPosition)
    {
    GameObject[] gos = null;
    switch (animal)
    {
    default:
    return false;

    case Crab:
    gos = GameObject.FindGameObjectsWithTag(crabtag);
    break;

    case Turtle:
    gos = GameObject.FindGameObjectsWithTag(turtletag);
    break;

    case Jelly:
    gos = GameObject.FindGameObjectsWithTag(jellytag);
    break;
    }

    if (!gos || gos.Length == 0)
    {
    return false;
    }

    foreach(GameObject go in gos)
    {
    if (playerPosition.x == go.transform.position.x playerPosition.y == go.transform.position.y)
    {
    return true;
    }
    }

    return false;
    }



    The main problems with your code were:



    Hard to read.


    Hard to debug.


    Float comparison as @fafase pointed out. You should consider using Mathf.Approximately or use Vector.sqrMagnitude:
    if (playerPosition - go.transform.position).sqrMagnitude 1.0f

  • RELEVANCY SCORE 2.49

    DB:2.49:Problem In Package Run Inside Stored Procedure k7


    i have ssis package to import data from excel to database.
    package is running correctly inside BIDS.
    but when i run package under stored procedure it is giving error :
    Error: Code: 0xC0014023
    Source: loop sheets in excel
    Description: The GetEnumerator method of the ForEach Enumerator has failed with error 0x80040E21 (null). This occurs when the ForEach Enumerator cannot enumerate.

    DB:2.49:Problem In Package Run Inside Stored Procedure k7

    Hi BI_DEV_19,
    Does the package connects with network resources? If so, try set the job step to run under a proxy account that is created based on a domain account. In BIDS, the package runs under the Windows account that you log onto the operating system.

    The error message “The GetEnumerator method of the ForEach Enumerator has failed with error 0x80040E21” may occur because the ADODB.dll file is corrupted or missing. You can check whether the ADODB.dll exists in the following folder:
    C:\program files (x86)\Microsoft.NET\Primary Interop Assemblies
    In this situation, you can back up the existing ADODB.dll file, and copy one from another machine to this server.
    Regards,Mike Yin
    TechNet Community Support

  • RELEVANCY SCORE 2.49

    DB:2.49:Start-Job -Scriptblock Doesnt Read -Argumentlist When Is Run Inside Foreach Loop 8k


    Hi,
    It seems that when I try to run start-job cmdlet inside foreach or foreach-object loop it doesn't read -ArgumentList:
    instruction

    foreach ($dc in $dclist) {start-job -argumentlist $dc.name -scriptblock {write-host $args[0].name} -name test}

    DB:2.49:Start-Job -Scriptblock Doesnt Read -Argumentlist When Is Run Inside Foreach Loop 8k

    I ran previous command with some modification:

    Get-QADComputer -ComputerRole domaincontroller|ForEach-Object{start-job -argumentlist $_ -ScriptBlock {write-host $args[0].name} -name test}

  • RELEVANCY SCORE 2.47

    DB:2.47:Loop Through Partially Filled Array Of Objects cx



    just insert a line like this at the start of the loop:

    for(int i = 0; i array.Length; i++) {
    if(array[i] == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    or, with a foreach loop:

    foreach(GameObject go in array) {
    if(go == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    This will skip all the following code inside the loop and go on with the next array element.

    DB:2.47:Loop Through Partially Filled Array Of Objects cx


    If you're using C# you could use a HashSet. It both allows you to do a foreach, and also to Add and Remove elements with reasonable speed. An array is probably not the best choice for something which grows and shrinks dynamically.

  • RELEVANCY SCORE 2.47

    DB:2.47:I Dont Know How To Capture The Variable Value Which Is Currently Being Used Within The Foreach Loop. dj


    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

    DB:2.47:I Dont Know How To Capture The Variable Value Which Is Currently Being Used Within The Foreach Loop. dj

    The current variable in the loop context is what you have setup on the Variable Mappings page of the For Each Loop editor.
    Teh value is captured in the variable, so what do you want to do next? Use the variable as you wish.
    You can check the variable if you want, set a break-point within the loop, and use the Watch window, dragging the variable in, or the Locals window.http://www.sqlis.com | http://www.konesans.com

  • RELEVANCY SCORE 2.47

    DB:2.47:Inside Foreach Loop Executenonquery Is Not Working j3


    Hi,
    I am very new to C# programming. I am facing one problem to execute insert query inside foreach loop.

    conn.Open();

    foreach(DataRowrow1
    indt.Rows)

    { CustNo = (row1[

    CustNo].ToString());

    CustName = (row1[

    CustName].ToString());

    cmd.CommandText =

    insert into mytable(id,CustNo,CustName) values(
    id , CustNo
    ,' CustName
    ');
    cmd.ExecuteNonQuery(); -------------- if i givethis statementoutside the foreach loop its inserting last row into table. but i need to insert all data table rows.

    }
    conn.Close();
    Whats thew wrong in the code?
    please give your suggestion.
    thank you

  • RELEVANCY SCORE 2.47

    DB:2.47:Export Csv Inside If Loop ak


    Hello Experts ,
    I have created a Powershell script which will query Active directory to list out all the windows server Operating system. Below is my script

    $a = Get-ADComputer -filter * -SearchBase DC=ad,DC=com -properties Operatingsystem
    Foreach ($os in $a)
    {
    If($os.Operatingsystem -match windows server *)
    {
    $os.Name , $os.Operatingsytem
    }
    }
    Now , I want to export this list to a CSV File ,
    The CSV File should contain 2 coulms , Namely ComputerName and OperatingSystem.
    I have never used Export-CSV , Not sure I can use it in my If loop.
    Can someone Help me in accomplishing this?
    Thanks,
    _Prashant_MCSA|MCITP SA|Microsoft Exchange 2003 Blog - http://prashant1987.wordpress.com Disclaimer: This posting is provided AS-IS with no warranties/guarantees and confers no rights.

    DB:2.47:Export Csv Inside If Loop ak

    Thanks Guys for making me understad how to use Label and Experssion ,
    I used ,
    $list | Export-Csv -Path d:\file.csv -notype to Exclude Type information :)
    Thanks,
    _Prashant_

    MCSA|MCITP SA|Microsoft Exchange 2003 Blog - http://prashant1987.wordpress.com Disclaimer: This posting is provided AS-IS with no warranties/guarantees and confers no rights.

  • RELEVANCY SCORE 2.47

    DB:2.47:Fox Formular Loop a1



    Hi,

    I would like to multiply a keyfigure with a percentage-value inside a loop. The code looks like this:

    DATA QUARTAL TYPE 0CALQUARTER.

    DATA PVALUE TYPE I.

    PVALUE = { 0PERCENT, # ,'0000000000000500', 'I', YASPARA }.

    FOREACH QUARTAL.

    IF QUARTAL '#'.

    { 0AMOUNT, QUARTAL, '0000000000000700', # , YASPLAN } =

    { 0AMOUNT, QUARTAL, '0000000000000700', # , YASPLAN } * PVALUE.

    ENDIF.

    ENDFOR.

    After i run the function, i always get 0 for all quarters although before the function there are different values. After debugging using a BREAK-POINT i found out that before the loop PVALUE is 30 and inside the loop becomes 0. Any suggestions why PVALUE is set to 0 in the loop?

    Thanks,

    Holger

    DB:2.47:Fox Formular Loop a1


    Dear Hogler,

    Can you once try adding this line after the statment PVALUE = { 0PERCENT, # ,'0000000000000500', 'I', YASPARA }. in your original code?

    MESSAGE I001(UPF) WITH 'Percent is ' PVALUE.

    and see what output you get?

  • RELEVANCY SCORE 2.47

    DB:2.47:Loading Text Data Into Sql Using Foreach Loop Continer aa


    Dear All,
    I have two textfile in my source folder
    i am able to load multiple text file with same strucure in sql using foreach loop container.in FOREACH LOOP CONTAINER i take one dataflow task where source is text and destination is sql
    created a variable which taking only text file
    my question s can i tale two dataflow task in foreach loop container to fetch dirrent structure text file.

    regards,
    Vipin jha

    DB:2.47:Loading Text Data Into Sql Using Foreach Loop Continer aa

    Sure. But you need to check first which dataflow you need to use.
    I guess you can determine from the filename which structure it is?
    Put a script task before your 2 dataflows. Inside the script task, check the filename and set a variable accordingly.
    Connect the script task to the dataflows using 2 precedence constraints.
    Put an expression on each precedence constraints. For example:
    @WhichDataflow == 1MCTS, MCITP - Please mark posts as answered where appropriate.

  • RELEVANCY SCORE 2.46

    DB:2.46:Strange Linq Behavior 7d


    Hi, can anyone tell me why linq evaluator remembers references of all objects in expression. Code example
    using System;
    using System.Collections.Generic;
    using System.Linq;
    namespace LinqTest
    {
    public class ExampleTestObject
    {
    public decimal Data { get; set; }
    }

    class Program
    {
    static void Main(string[] args)
    {
    ListExampleTestObject cCollection = new ListExampleTestObject();

    cCollection.Add(new ExampleTestObject() { Data = 1 });
    cCollection.Add(new ExampleTestObject() { Data = 2 });
    cCollection.Add(new ExampleTestObject() { Data = 3 });
    cCollection.Add(new ExampleTestObject() { Data = 4 });

    ListFuncExampleTestObject, bool cFilters = new ListFuncExampleTestObject, bool();

    foreach (ExampleTestObject obj in cCollection)
    {
    //ExampleTestObject oReferenced = obj;
    //cFilters.Add(o = o.Data == oReferenced.Data);
    cFilters.Add(o = o.Data == obj.Data);
    }

    ExampleTestObject oTestObject = new ExampleTestObject() { Data = 4 };
    foreach (FuncExampleTestObject, bool oFilter in cFilters)
    {
    Console.WriteLine(oFilter(oTestObject).ToString());
    }
    }
    }
    }

    This code returns for times yes, because it evaluates lambda expression by passing the last object in the foreach loop. If you replace foreach body with commented code, every thing works more intuitive:false, false, false,true.

    udione

    DB:2.46:Strange Linq Behavior 7d

    You are only dealing with a single variable in the foreach (ExampleTestObject obj), although it is being set multiple times as you iterate through the collection. The lambda acts on the variable, not the value contained in that variable, so it will print True four times because that is the current value contained in that variable at the end of the loop. Your commented out code will work as you intended because it is introducing a brand new variable each time through the loop and using that for a given lambda, in effect, pointing each lambda to a different variable.

  • RELEVANCY SCORE 2.46

    DB:2.46:How To Use Foreach Loop Container Task? ac


    SQL Server 2005 SSIS  I need to process all text files in a folder to first bulk insert data from a file into a staging table and do some further processing. I am trying to use ForEach Loop container with a bulk insert task within it. However, I get an error for the bulk insert task - The specified connection source file is either not valid or points to an invalid object . This is my first time using the foreachloop and may be I didnt set it up correctly. Can someone help me resolve this? Following are the steps I took for the setup.1. Create destination oledb connection2. Create source flat file connection -- I chose one of the many text files as source from the folder I want to loop.3. Create a ForEach Loop Container task4. Drag bulk insert task inside the foreach loop in step 3.5. Edit Enumerator (Foreach file enumerator) configuration foreach loop -- Folder = C:\SourceFolder, Files - *.txt, Retrieve FileName = Fully qualified.6. Edit Variable Mappings for Foreachloop - create new variable varFileName - scope Package, namespace = user.7. Edit source file connection created in step 2 - Source File connection properties - Expression - ConnectionString Property = @[User::varFileName].8. Edit  connections in Bulk insert task- set up the appropriate Destination connection created in step 1 and source connection created in step 2. Am i missing something? Thanks in advance for your help.

    DB:2.46:How To Use Foreach Loop Container Task? ac

    Thanks Eric. I will try this.One thing I noticed is the source file flat file connection is reset after #7. i.e. in step 2 I set up file name to one of the files in my folder but after setting up the connetion property in #7, if I double click the source file I do not see file name in the connection manager editor. Am I not setting up the source file correctly?Also is there a way to debug to see whether or not the loop is working? Something like print file name

  • RELEVANCY SCORE 2.45

    DB:2.45:Ssis Error Message 8x


    I have created a package with a forEach loop and several tasks inside I went to move to package handlers and I received this message
    One or more errors occurred while adding components to the tree. The following components may not have been added to the tree properly:
    Component 'Foreach Loop Container': Exception from HRESULT: 0xC0010014
    I have been having lots of trouble with this package, cant add or delete tasks, cant set precedence constraints.
    Can anyone help?

    DB:2.45:Ssis Error Message 8x

    We are using Sql Server 2005 SP2 and
    Microsoft Visual Studio 2005
    Version 8.0.50727.42 (RTM.050727-4200)
    Microsoft .NET Framework
    Version 2.0.50727 SP2
    Installed Edition: IDE Standard
    SQL Server Analysis Services
    Microsoft SQL Server Analysis Services Designer
    Version 9.00.4035.00
    SQL Server Integration Services
    Microsoft SQL Server Integration Services Designer
    Version 9.00.4035.00
    SQL Server Reporting Services
    Microsoft SQL Server Reporting Services Designers
    Version 9.00.4035.00

  • RELEVANCY SCORE 2.45

    DB:2.45:Labview Thread 11



    Dear All,

    I want to know how labview form threads from a user created VI. I have a VI in which I have a while loop that contains a wait function and some other code both are running in parallel(data independent). I want to know the following things with reagrd to this VI

    1. How labview creates threads form this VI, how many threads will be created?

    2. If we are not using any sequence structures inside the loop, whether labview will follow any particular repeated sequence for this code?(Like it will execute wait function first, and code after that ...) or labview will follow any random order for this threads for each loop iteration?




    Best regards,Pradeep Kumar Mishralove to do engineering

    DB:2.45:Labview Thread 11


    HiiGerdW,

    Can you please suggest me some links ..

    Thanks

    PKMishra




    Best regards,Pradeep Kumar Mishralove to do engineering

  • RELEVANCY SCORE 2.45

    DB:2.45:Foreach Loop - Value Back To 0 f9


    Hi,
     
    Let's say you have a Data Flow Task that connects to a Foreach Loop, looping through the data.
     
    Somewhere inside the Foreach Loop, you set an int variable MyInt to a value.
     
    My question:
    Is it possable when each iteration begins to set MyInt to 0?
     
    Thanks in advance.

    DB:2.45:Foreach Loop - Value Back To 0 f9

    But you could set it by running SELECT ? = 0 inside an Execute SQL task at the start of your loop, and assigning that output parameter to your variable.

  • RELEVANCY SCORE 2.44

    DB:2.44:Ssis Expressions Problem ac


    Hi All,

    Please help on the SSIS issue.

    i have a package.It contains Foreach loop container,Inside foreach loop container,I have one Dataflow task(Inside dataflow task,i am using Oledb source(table),I am populating

    Data into Flat file)with flat file name YYYYMMDD_HH24MISS.txt. After i want to Zip that file with same file name.
    YYYYMMDD_HH24MISS.txt.zip,After that i want copy that Zip file into another location.

    Thanks in advance...

    DB:2.44:Ssis Expressions Problem ac

    Hi BADDULAS,
    According to the screenshot in your initial post, you are using an Execute Process Task to compress the .txt file generated by the Data Flow Task. Let’s assume that you are using the common free software 7-Zip as the executable of the Execute Process Task,
    then you can refer to the following blog:
    http://sqlage.blogspot.com/2013/12/ssis-how-to-compress-and-archive-file.html
    To get the expected name for the txt file, you can create another String type SSIS variable @[User::FileName] using the following expression (set EvaluateAsExpression property of the variable to True):
    REPLACE(SUBSTRING((DT_STR,30,1252)GETDATE(),1,10),-,)_ SUBSTRING((DT_STR,30,1252)GETDATE(),12,2) 24MISS.txt

    The FileName variable should be used by the ConnectionString property of the Flat File Connection Manager that is used by the Flat File Destination in the Data Flow Task.
    Besides, the variable FileName should also be used in the expression of the VarSourcePath variable and the VarArchivePath variable as follows:
    VarSourcePath: “C:\\Temp\\Source\\” @[User::FileName]
    VarArchivePath: “C:\\Temp\\Destination\\” REPLACE(@[User::FileName], ”.txt”, “”)

    Regards,Mike Yin
    TechNet Community Support

  • RELEVANCY SCORE 2.44

    DB:2.44:Loop Through Partially Filled Array Of Objects cm



    just insert a line like this at the start of the loop:

    for(int i = 0; i array.Length; i++) {
    if(array[i] == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    or, with a foreach loop:

    foreach(GameObject go in array) {
    if(go == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    This will skip all the following code inside the loop and go on with the next array element.

    DB:2.44:Loop Through Partially Filled Array Of Objects cm


    If you're using C# you could use a HashSet. It both allows you to do a foreach, and also to Add and Remove elements with reasonable speed. An array is probably not the best choice for something which grows and shrinks dynamically.

  • RELEVANCY SCORE 2.44

    DB:2.44:Failparentonfailure, Transactions And Sql Agent Job Failure 3f


    I have a package with a foreach loop container. The container fails as expected, due to one of the tasks failing. The next task after the container is a SQL task and this executes fine as well, but the execution stops there. Why? See
    screenshot below.
    The package is using TransactionOption = Supported
    The various tasks inside the foreach loop and inner container are set to Supported also.
    The tasks outside inner container, but inside the foreach loop (the ones Im having trouble with) are marked as Not Supported. Why isnt the next task (see arrow) executing? In the Execution results tab of the package, I see the script
    task that follows the sql task , its validated but never executed....

    DB:2.44:Failparentonfailure, Transactions And Sql Agent Job Failure 3f

    Since you use Subversion it is typical for it to treat binary portion of a file as image and treat the whole file as binary and it reloads it differently, I am no expert in Subversion so I may be partially correct / incorrect, but here is the thing, stay
    away from using 3rd party source control tools with SSIS. I know from my experience that it may break packages.Arthur My Blog

  • RELEVANCY SCORE 2.44

    DB:2.44:How To Find Controls In Grid View dp


    Hi,
    I have Created a Form Inside a GridView Tool, but now I am facing problem to find the controls that are inside it, i.e. Textbox,Label. I know there must be a Foreach Loop for this but still I am unable to deploye this code. If anybody have Answer with Example
    please let me know, as i have need it on urgent basis.
    Thnx

    DB:2.44:How To Find Controls In Grid View dp

    Hi,
    Kindly try this
    protected void MyGridView_RowDataBound(object sender,
    GridViewRowEventArgs e) -- Event
    {
    if (e.Row.RowType
    == DataControlRowType.DataRow)
    {
    Label lbl_Name
    = (Label)e.Row.FindControl(lblName); ---Your label Name
    lbl_Name.Text
    = Name;
    }
    }
    Thanks

  • RELEVANCY SCORE 2.44

    DB:2.44:Foreach File Action When No Files Exist ss


    I have a ForEach Loop that loops through files. Within the container, I have a script task that builds an HTML table where a row is created and populated with each file name found.
    If there are no files, the script task does not execute (?). How can I set up a condition for the rest of the package not to execute if the ForEach Loop finds no files?
    Thanks.
    cdun2

  • RELEVANCY SCORE 2.44

    DB:2.44:Trouble Grabbing Wpfcells Inside A Wpfrow Inside A Wpftable Using Cells Uitestcontrolcollection as


    Greetings!
    I'm seeing some very strange behavior with some WpfCells inside WpfRows inside WpfTables. What's strange about it is everything works fine (as fine as CUIT can be with WPF controls) until it gets to the WpfCells layer.
    What I mean is, I've done something like this:
    WpfTable table = new WpfTable(page);
    UITestControlCollection coll1 = table.Rows;
    If I loop through coll1, it shows a collection of WpfRows as expected. So, next I've done something like this:
    foreach (WpfRow r in coll1)
    {
    WpfRow row = new WpfRow(table);
    row.CopyFrom(r);

    UITestControlCollection coll2 = r.Cells;
    }
    This is where my problem first starts. I've checked it out, and coll2 comes up with a Count of 0. This is particularly strange because of what I did next:
    foreach (WpfRow r in coll1)
    {
    WpfRow row = new WpfRow(table);
    row.CopyFrom(r);

    UITestControlCollection coll2 = r.GetChildren();
    foreach(UITestControl i in coll2)
    {
    MessageBox.Show(i.GetType().ToString());
    }
    }
    Each one of these Message Boxen will display Microsoft.VisualStudio.TestTools.UITesting.WpfControls.WpfCell, which is what I would expect. I'm not exactly certain why row.Cells doesn't work even though each WpfRow verifiably contains WpfCells.
    Is there something weird about the Cells call (which should return a UITestControlCollection of WpfCells) that I'm missing?
    Thanks very much!!

    DB:2.44:Trouble Grabbing Wpfcells Inside A Wpfrow Inside A Wpftable Using Cells Uitestcontrolcollection as

    Hi,
    I know you have tried r.Cells and it is not working as expected. The keypoint in my last reply is to call r.Cells against second row, third row etc. Be aware of the RowHeaders property of WpfTable.
    In your latest experiment code, I've no idea what's the WpfControl at beginning of each row. Due to complexity of this issue, it falls into paid support category which need high-level of support. Please visit the below link to see the various support
    options that are available to better meet your needs.
    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    best regards,Forrest Guo | MSDN Community Support |
    Feedback to manager

  • RELEVANCY SCORE 2.44

    DB:2.44:Foreach Loop Enumerator With Multiple File Names j7


    I have an SSIS package with a Foreach Loop container. I want to process all files beginning with Export_Job8*.txt orExport_Job9*.txt. Is it possible to specify this in a single ForEach Loop container?

    DB:2.44:Foreach Loop Enumerator With Multiple File Names j7

    Thanks so much for your help SSISJoost! I'm a .NET developer, but new to SSIS. I needed to get my feet wet in the debugger, and you were a big help.

  • RELEVANCY SCORE 2.43

    DB:2.43:How Create Excel Destination Dynamiclly On Fly Using Ssis 39


    Hi Techies,
    I created a package, in that i placed ForEach Loop Container inside that i placed DFT. I am using Excel Source and Excel Destination.
    For reading the multiple files we used Foreach loop container component and we are able to read the multiple files dynamically, up to here everything is fine.
    But the problem is that we need to create the files(.xls or .csv) dynamically with the name as input file name at destination.
    Is there any way to create EXcel Destination file Dynamically?

    Thanks in advance...

    Chandu

    DB:2.43:How Create Excel Destination Dynamiclly On Fly Using Ssis 39

    Hi,
    Here is some example that shows creating multiple destination files on the fly. I think you can use thistechnique
    http://consultingblogs.emc.com/jamiethomson/archive/2005/12/04/SSIS-Nugget_3A00_-Splitting-a-file-into-multiple-files.aspx

    http://bi-polar23.blogspot.in/2008/02/dynamic-flat-file-destinations.html

    Regards
    Satheesh

  • RELEVANCY SCORE 2.43

    DB:2.43:Problem Trying To Loop Through Elements jx


    I have an itemscontrol that's populated with checkboxes. When a user updates their profile I need to loop through these checkboxes, get the datacontext, which is a UserTypeElement class I created and grab the ID. This is what I'm trying to use to loop
    through them:
    var checkedItems = from item in edit_roles_itemscontrol.Items.CastCheckBox()
    where Convert.ToBoolean(item.IsChecked)
    select item.DataContext as UserTypeElement;

    foreach (var item in checkedItems)
    {

    }
    It errors on the word in inside the foreach loop saying it can't cast object type UserTypeElement as Checkbox.
    I'm not sure where that cast is taking place that it's choking on, I've tried several things to fix it to no avail.

  • RELEVANCY SCORE 2.42

    DB:2.42:[Flat File Source [1]] Error: Cannot Open The Datafile Filename_Yyyymmdd.Csv. 3x


    Do you know why I get this message in the subject line in ssis?
    I am using a foreach loop container. Inside it there is dataflow with fileconnection as expression to the filename
    Any thoughts please?
    Thanks

    DB:2.42:[Flat File Source [1]] Error: Cannot Open The Datafile Filename_Yyyymmdd.Csv. 3x

    How you are passing connection string. Are you passing connection string dynamically trough variables or directly feeding only this file??

  • RELEVANCY SCORE 2.42

    DB:2.42:How To Use Parellel Foreach Loop In Gridview Row. xk


    foreach (GridViewRow row in grdSearch.Rows)
    {
    CheckBox cbox = (CheckBox)row.FindControl(VerifyRow);
    if (cbox.Checked == true)
    {

    string value = row.Cells[11].Text.Trim().ToString();
    calculate(value);
    }
    }
    For the above foreach loop i want to execute this using multiple threads.

    DB:2.42:How To Use Parellel Foreach Loop In Gridview Row. xk

    I have found my solution finally. In case anybody looking for the same solution. here it is how i did.

    grdSearch.Rows.CastGridViewRow().Where(
    r = ((CheckBox)r.FindControl(VerifyRow)).Checked).AsParallel().ForAll(row =
    {

    string value = row.Cells[11].Text.Trim().ToString();

    calculate(value);

    });

  • RELEVANCY SCORE 2.42

    DB:2.42:Foreach Loop zp


    Hi,
     
    How do I use thisID and thisCD variables in the foreach loop without having to place the if statement inside the loop?#
     
    Thanks.
     

    Code Block

    DB:2.42:Foreach Loop zp

    Hi,
     
    I am a little confused by the code you provide...
    Why itterate the RRef table with a for loop?  Is this not just setting GPositionID to the last row of RRef?
    Alternatively, did you intend to do more in the following loop?
     

    Code Block

  • RELEVANCY SCORE 2.42

    DB:2.42:Question In Parallel Programming/Multithreading C# mc


    I am currently developing a load simulator tool which supposedly should post requests continuously(preferably in a parallel manner) to the service application, an abstract view of the application code is given below

    I am iterating through an input collection

    foreach (var input in inputColl)
    {
    //validation
    this.Run(input)

    }
    The below method actually calls API available in the service application

    void Run(object input)
    {
    //API call

    }
    When i execute this code as such, it works fine. But I preferred to make the Run method execute in a parallel manner rather than being sequential, so used the below provisions(one at a time),
    1. Using BeginInvoke by assigning a delegate to Run method
    foreach(var input in inputColl)
    {

    Actionobject caller = this.Run;

    //asyncResults is ListIAsyncResult collection
    this.asyncResults.Add(caller.BeginInvoke(input, null, null));
    }
    foreach(IAsyncResult t in this.asyncResults)
    {
    t.AsyncWaitHandle.WaitOne(waitInterval);

    }

    2. Created several tasks for the number of input requests to be posted using Task.Factory.StartNew method
    //foreach
    {
    //tasks is ListTask collection
    this.tasks.Add(Task.Factory.StartNew(new Actionobject(this.Run), input));
    }
    Task.WaitAll(tasks.ToArray())

    3. Creating new Threads (although this is relatively expensive) using Thread class.
    //foreach
    {
    Thread thread = new Thread(new ParameterizedThreadStart(this.Run));
    //threads is ListThread collection
    this.threads.Add(thread);
    thread.Start(input);
    }
    foreach(Thread t in this.threads)
    {
    t.Join();
    }
    Everytime I create a new thread(inside foreach) using one of the above method I take a reference to either IAsyncResult or Thread or Task objects so that the Parent thread can be made to wait until all of the spawned threads completes before closing the
    application.
    The problem I face with all of these approaches is that the application closes before the long running requests among the created ones are completed successfully. Ex: Consider 2 threads are spawned and thread 2 is relatively a long running request comparing
    to thread 1. Here thread 1 completes successfully and i could see data posted to the service but the status of thread 2 remains unknown, i could neither see any data posted to server nor any logs recorded in this tool.

    Sorry for the long description, just making sure that i don't miss anything..So coming to the problem again, am obviously missing something, would be glad if anyone could clarify this question.

    deva_8907

    DB:2.42:Question In Parallel Programming/Multithreading C# mc

    Hello Deva_8907,
    As you point out there are many ways to accomplish what you are trying to do.

    The following snippet is how I approached it in the test project of sample
    project I did about multi-threading:
    for (int model = 0; model 100; model)
    {
    string key = string.Format(Model:{0}, model);

    for (int thread = 0; thread 30; thread)
    {
    TaskTimeSpan task = UpdateDictionaryModel(key);
    task.Start();
    dictionaryTasks.Add(task);

    task = UpdateLockedDictionaryModel(key);
    task.Start();
    lockedTasks.Add(task);

    task = UpdateConcurrentDictionaryModel(key);
    task.Start();
    concurrencyTasks.Add(task);
    }
    }

    // waitall will throw an aggregate exception for each failed task
    // TaskTimeSpan.WaitAll(tasks.ToArray());
    while (dictionaryTasks.Any(t = t.Status == TaskStatus.Running)
    || lockedTasks.Any(t = t.Status == TaskStatus.Running)
    || concurrencyTasks.Any(t = t.Status == TaskStatus.Running))
    {
    Thread.CurrentThread.Join(200);
    }

    Here is another approach from the another unit test:
    // launch some clients
    Dictionarystring, ListTask clients = new Dictionarystring, ListTask
    {
    {AuditTestClient1, new ListTask()}
    };

    // start clients with auditing talking to service with auditing
    for (int i = 0; i 1; i)
    clients[AuditTestClient1].Add(Task.Factory.StartNew(ClientTestRunner.StartCustomerClient(AuditTestClient1)));

    // wait until each finishes
    clients.Values.ForEach(l = l.ForEach(f = f.Wait()));

    Take a look at the unit test project for some examples for this sample
    project:
    Jeff

  • RELEVANCY SCORE 2.42

    DB:2.42:Querying Random Number Of Elements, Linq fk


    I'm outputting one element of an XML document to a windows form using LinQ in C# (2008 ve beta) and I'm having trouble with there being a random number of elements.  For example here is the document.xml outline
     

    [...]

     
    [...] random number of [...]
     

    [...]

    [...]

     
    I've built the code to display everything but the ingredients, displayed below.  I think I will have to next a foreach loop inside my current foreach loop to do this but the syntax I've tried has all been deadends.  Does anybody have any experience with this in Linq?
     

    Code Block

    DB:2.42:Querying Random Number Of Elements, Linq fk

     
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2342388SiteID=1
     
    This question was answered here.  Thanks to JRBoddie for the code sample.

  • RELEVANCY SCORE 2.42

    DB:2.42:Foreach Loop Erro While Creating Procedure? 3d


    hello all, i am creating a proceudre with foreach loop, created with compilation error. please correct me if some mistake is there...

    CREATE PROCEDURE update_list
    DEFINE name VARCHAR(30);
    DEFINE address VARCHAR(255);
    begin
    FOREACH namedCursor FOR
    SELECT ename, eaddress INTO name, address FROM emp
    INSERT INTO mailing_list VALUES(name, address);
    IF(ename="McAllister") THEN
    UPDATE emp SET sal = sal + 2000 WHERE CURRENT OF namedCursor;
    CONTINUE FOREACH;
    END IF
    UPDATE emp SET sal = sal + 1000 WHERE CURRENT OF namedCursor;
    END FOREACH;
    END PROCEDURE

    thanks
    yash

    mailing_list table is created with field.

    DB:2.42:Foreach Loop Erro While Creating Procedure? 3d

    Double post - here is the answered thread: {thread:id=2272279}

  • RELEVANCY SCORE 2.41

    DB:2.41:How To Get File Name From Foreach Loop s7


    i have a for loop inside that i have put a script task ...
    inside that script task i want to show a message box with file name from the foreach loop...
    i mean in the first..when the foreach takes the first file i want to show that in popup and when the foreach takes the second file then i want to show the popup...how to do that...ilikemicrosoft

    DB:2.41:How To Get File Name From Foreach Loop s7

    If the go to the same destination, you can add a File System Task within the Foreach Loop. Set UsSourcePathVariable to True and select your variable at SourceVariable. Now they will go one by one, but all to the same destination folder.
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • RELEVANCY SCORE 2.41

    DB:2.41:Faq Item: How Do I Remove An Item In From A Generic List Inside A Foreach Loop? zx


    How do I remove an item in from a generic list inside a foreach loop?

    DB:2.41:Faq Item: How Do I Remove An Item In From A Generic List Inside A Foreach Loop? zx

    It is not possible to remove an item from a generic list inside the foreach loop. The underlying collection cannot be modified when enumeration. If we try to remove
    an item, we will receive an error,
    Collection was modified; enumeration operation may not execute.
    The standard approach is to keep track of the items to remove and then after all of the items are enumerated, loop the to be removed items list, and
    remove each item from the original collection.
    Wrong version codes:

    System.Collections.Generic.Listobject list = new Listobject();

    for (int i = 0; i = 19;i )

    {

    list.Add(i / 10);

    }

    foreach (object o in list)

    {

    if (System.Convert.ToInt32(o) == 1)

    {

    list.Remove(o);

    }

    }
    Right version codes,

    System.Collections.Generic.Listobject list = new Listobject();

    for (int i = 0; i = 19;i )

    {

    list.Add(i / 10);

    }

    ArrayList arraylist = new ArrayList();

    foreach (object o in list)

    {

    if (System.Convert.ToInt32(o) == 1)

    {

    arraylist.Add(o);

    }

    }

    foreach (object o in arraylist)

    {

    list.Remove(o);

    }
    Related threads:
    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/16c6e628-bce8-4386-9455-fd4fb577532a
    http://social.msdn.microsoft.com/forums/en/netfxbcl/thread/7ce02724-2813-4f7d-8f3c-b1e3c1fd3019/

    For more FAQ about Visual C#
    General, please see

    Visual C# General FAQ

  • RELEVANCY SCORE 2.41

    DB:2.41:Foreach Loop Container And Foreach File In Folder zk


    Hi
    i'm trying to import multiple files with bulkinsert task and foreach loop container.
    the bulkinsert task works without the foreach container.
    I have add the foreach loop contanier according the example in tutorial for sql 2005
    lesson 2.adding looping.
    what i can se it's the connection that is wrong .
    what am i missing ?ge

    DB:2.41:Foreach Loop Container And Foreach File In Folder zk

    Have a look here http://blogs.conchango.com/jamiethomson/archive/2005/05/30/SSIS_3A00_-Enumerating-files-in-a-Foreach-loop.aspx
     Ashwani Roy
    http://ashwaniroy.spaces.live.com/
    Please click the Mark as Answer button if a post solves your problem!

  • RELEVANCY SCORE 2.40

    DB:2.40:When Do We Go With Foreach Loop Statment In Bi-Ip mm



    Hey Folks,

    I am wanted to know more information about FOREACH Loop statement in IP while creating Formula PF.

    when do we use FOREACH Loop statement..? what are business scenariou2019s to use it..?

    Can some give lights on this...

    Thanks,

    Venkat Vanarasi

    DB:2.40:When Do We Go With Foreach Loop Statment In Bi-Ip mm


    Dear Martin Maruskin,

    Thank you very much for you helpfull informatin on my request.

    I given points to you.

    Thanks,

    Venkat.

  • RELEVANCY SCORE 2.40

    DB:2.40:Foreach Loop Within A Foreach Loop z9


    hey guys I am having trouble with advancing my variable in foreach loop. I have a foreach loop within a foreach loop and it is supposed to compare file extensions of every files inside both directories I am passing in.
    The problem is that the second foreach loop compares the extension of its each file with only the first file that it receives from the first foreach loop. In other words, the first foreach loop never advances to the second file in the directory.
    Is there something I am doing wrong? Should I be using a different loop instead of foreach loop?
    I would really appreciate any help.

    - Thanks

    foreach (FileInfo file in dir.GetFiles())
    {



    bool forExtension = false;

    foreach (FileInfo file2 in dir2.GetFiles())
    {


    if(file.Extension == file2.Extension)
    {
    forExtension = true ;
    }
    else
    {
    forExtension = false ;
    }
    }

    if(forExtension == true)
    {
    Console.WriteLine(Passed!);
    }
    else
    {
    Console.WriteLine(Failed!);
    }


    }

    DB:2.40:Foreach Loop Within A Foreach Loop z9

    Compare the extensions of all files from one directory to the extensions of all files from another directory?
    Dir1: a.txt, b.doc
    Dir2: c.txt, d.doc
    Fails because a.txt doesn't have the same extension as d.doc. Is that theexpected result?

  • RELEVANCY SCORE 2.40

    DB:2.40:Escape Characters Not Escaping... 3m


    Hello, all,
    I'm seeing some very bizarre behavior in SSIS 2008 R2. I have a variable that is used as the source for a WMI Data Reader query. The Data Reader task is inside a foreach loop. The foreach loop reads in file names from a directory and the
    WMI source variable is built the variable used to hold the file name in the loop.
    What's happening is, the escape characters I am using in the expression to keep the double quotes is being used when the variable is resolved. Here is some code to show what's happening:
    Variable @[User::vFindFile] - string, evaluated as an expression:
    SELECT Name FROM CIM_Datafile WHERE Name = \ @[User::vFileName] \ AND CreationDate \ @[User::vTestDate] \
    Variable @[User::vTestDate] - string, evaluated as an expression, used to build date/time WMI uses:
    (DT_WSTR, 4)DATEPART( yyyy, @[User::vFileCreateDate] ) (DT_WSTR, 2) DATEPART( mm, @[User::vFileCreateDate] ) (DT_WSTR, 2) DATEPART( dd, @[User::vFileCreateDate] ) 000000.000000-240
    Variable @[User::FileCreateDate] - datetime, used to set the date/age for which files I want to select
    DATEADD( dd, -20, GETDATE() )
    What I am expecting the query in vFindFile to look like when everything is evaluated is this:
    SELECT Name FROM CIM_Datafile WHERE Name = I:\\bak\\file1.txt AND CreationDate 20121127000000.000000-240
    And that is what I see when I test the evaluation when I build the expression (minus the file name because that is populated from the foreach loop). However, the WMI Data Reader task is failing with an error,

    Error: 0xC002F304 at WMI Data Reader Loop, WMI Data Reader Task: An error occurred with the following error message: Invalid query .

    When I set all the break points, step thru it and look at all the variables, I noticed that the query is actually coming out as:
    SELECT Name FROM CIM_Datafile WHERE Name = \I:\\bak\\file1.txt\ AND CreationDate \2012119000000.000000-240\
    For some reason, the slashes that preceed the double-quotes are not being removed. Has anyone seen this before? Am I doing something wrong that I am just missing? I thought this was pretty straight forward and have done with many times
    before, although not with a WMI Data Reader task. Maybe there's something specific to this I'm not aware of.
    Thanks for taking a look at this....
    Pete

    DB:2.40:Escape Characters Not Escaping... 3m

    Everyone,
    After stepping away from this for a while, I found a much better way of doing what I need to do. Instead of using WMI info to delete everything older than a given date, I can use the simple DOS command 'forfiles'. While I prefer the better security
    I can get in SSIS, I can just create a operating system job in the Agent and put the entire command right in there. In case anyone would like to see it, here it is:
    forfiles /P I:\bak /M *.txt /C cmd /c del @path /D -20
    It ended up being that simple, rather than going crazy with WMI stuff, trying to figure out how to compare the dates (that -240 at the end drove me bonkers), trying to figure whichclasses to use, etc. I'm just a little embarassed I forgot about
    this command.
    Anywho, thanks for everyone's input...
    Pete

  • RELEVANCY SCORE 2.40

    DB:2.40:Performing Parallel.Foreach Inside Another Parallel.Foreach s8


    Hello I am currently having some code that has a foreach loop inside another foreach loop. I wanted to switch this code so that both foreach loops use the Parallel versions. But I was not sure about the ramifications for larger loops. The inner loop contains
    a List collection that may be added to and therefore it will need to be locked. But I'm not sure if that lock will cause problems within the context of this multi loop scenario. Any suggestions are welcome. Here's some code I am thinking of trying. Will this
    code cause any severe blocking of threads? What are the advantages of using the new Queue collections? Should I be using the SyncRoot or just create an object sync token?

    Parallel.ForEach(stockInfos, s =
    {
    if (mktImpacts != null)
    {
    Parallel.ForEach(mktImpacts, mktImpContainer =
    {
    if (mktImpContainer.OrderId.ToLower() == s.OrdId.ToLower())
    {
    MarketImpactStockLevelInfoAggregate newAggregate = new MarketImpactStockLevelInfoAggregate();

    if (!string.IsNullOrEmpty(newAggregate.Side))
    {
    newAggregate.Symbol = s.Symbol;
    newAggregate.OrdId = s.OrdId;
    newAggregate.Curr = s.Curr.ToString();
    newAggregate.Exch = s.Exch.ToString();

    lock (((System.Collections.IList)finalModels).SyncRoot)
    {
    finalModels.Add(newAggregate);
    }
    }
    }
    });
    }
    else
    {
    // rest of code below is not shown

    DB:2.40:Performing Parallel.Foreach Inside Another Parallel.Foreach s8

    There are a lot of questions here -

    First, two nested parallel loops is rarely a beneficial thing to do. The outer loop typically provides plenty of opportunities for concurrency - if you only have 4 or 8 cores, just leaving the outer loop parallelized will provide plenty of opportunity
    for concurrency, so I would recommend only using a single parallel loop here.

    But I'm not sure if that lock will cause problems within the context of this multi loop scenario.
    Provided you lock correctly, this will be fine.
    Will
    this code cause any severe blocking of threads?
    It depends on how often this is hit. Only one thread will be able to work inside of this lock at a time, so you're
    likely to have a bottleneck here, especially if many items are matching your criteria. In this case, you're doing very, very little work in the method, so I suspect your lock will block, and you'll likely find little benefit to running this in parallel
    (using this method).
    What
    are the advantages of using the new Queue collections?
    If you use the collections in

    System.Collections.Concurrent, you can avoid having the lock. This will likely cause the entire operation to scale much more effectively.
    Should
    I be using the SyncRoot or just create an object sync token?
    I typically will always create a private object that I use as a sync token. You can use the SyncRoot, and it
    will work fine, as long as finalModels is not exposed to any other code. If other people try to use the same SyncRoot on the same collection, however, you're potentially exposing something that may be a problem. As such, I tend to just avoid
    the issue altogether.

    Any suggestions are welcome.

    I have three suggestions for you -
    First, I'd only use one parallel loop. Having two will likely cause it to slow down due to the overhead of parallelizing,
    and since you don't have enough processors to process all items from both loops, it'll likely be slower.
    Second, if you leave this method generally as written, I'd recommend converting this to use one of the concurrent collections,
    and removing the lock. This would allow this to scale much more effectively.
    Finally, I'd consider switching this to use PLINQ instead of Parallel.ForEach. From what I can see, you're effectively
    doing a query which is nothing but a join on mktImpacks and stockInfos. In this case, a PLINQ join will likely scale MUCH better, and be much simpler code, than what you're using right now.

    I also think there's a bug in your current code. See this:

    MarketImpactStockLevelInfoAggregate newAggregate = new MarketImpactStockLevelInfoAggregate();

    // This should always be true or always be false, depending on the
    // default constructor of MarketImpactStockLevelInfoAggregate
    // ????????????????
    if (!string.IsNullOrEmpty(newAggregate.Side))

  • RELEVANCY SCORE 2.40

    DB:2.40:Foreach Loop.. 7s


    I am using Foreach Loop to retrieve data from more than 400 tables. Inside the component I use script task to evaluate each single table that has different structure to get data then load the data into a target table, same inside Foreach loop.
    My question is can I free memory usage after loading table in each cycle? Because i found the foreach loop part of ETL package is pretty slow when executed from server's Agent.
    Or do you have any other suggestions?
    Appreciate your help.

    DB:2.40:Foreach Loop.. 7s

    What memory would you like to free?
    Why do you think that freeing this memory would increase performance?
    You imply that the performance of the package is poor in SQL Agent... is it better when executed from another environment?

    Talk to me now on

  • RELEVANCY SCORE 2.40

    DB:2.40:Pass Filename To Flatfilesource Inside Foreach Loop kk


     
    Hi,I am using a foreach loop to go through the .txt files inside a folder.Using a variable I can pickup the filenames the loop is going through.At present there is a sql task inside the foreach loop which takes the filename as a parameter and passes this filename to a stored procedure.Now I would like to add one extra step before this sql task. Would like to have a dataflow with flatfile source which connects to oledb destination.
    The question is:While in the loop, how is it possible to pass the filename to the flatfile source using the FileName variable which I have created?
    Please note, this is a different question to my other post.
    Many Thanks

    DB:2.40:Pass Filename To Flatfilesource Inside Foreach Loop kk

     
    You would create the filename variable at the package level and use it in both the flat file connection and the foreach loop.
     
    It will set the variable in the loop and use the variable in the connection manager.
     
    In other words, in the foreach loop, make sure that the foreach file enumerator is selected, choose the file name convention you would like to return (preferably fully qualified if you are using this with a flat file connection), go to the variables tab and choose your variable name (User::FileName which should be declared at the package level).  In your flat file connection go to your expressions and choose connectionstring as the property to edit.  Select the User::FileName as the variable.
     
    That should do it.

  • RELEVANCY SCORE 2.39

    DB:2.39:Using User Defined Function In Execute Sql Task Within Foreach Loop mc


    hi
     
    I am trying to execute a UDF in an Execute SQL Task within a Foreach loop.
    I have an Execute SQL task to get the dataset (Firstname, Lastname, CompanyID) which is going into a full result set called @PendingPar. The Foreach Loop is set to a Foreach ADO Enumerator against @PendingPar and I have created 3 variables at the Foreach Loop scope level called @Firstname (String), @Lastname (String) and @CompanyID (Int32). These are mapped in the Foreach Loop as index 0,1 and 2.
     
    Within the Foreach Loop I have an Execute SQL Task with the sql command
     
    select dbo.udf_GetParTitle (?,?,?)
     
    In the parameter mapping I have Variable Name = User::Firstname Direction = Input Data Type = VARCHAR and Parameter Name = 0, User::Lastname, Input, VARCHAR, 1 and User::CompanyID, Input, VARCHAR,2
     
    Finally the UDF returns a @NewPar value so i have the result set in the execute sql task to Single Row which goes into variable @NewPar. This @newPar will be used later but I cannot get the first bit to work yet.
     
    the error message i get back is
     
    Error: 0xC002F210 at Execute SQL Task 1, Execute SQL Task: Executing the query select dbo.udf_GetParTitle (?,?,?)
    failed with the following error: Syntax error, permission violation, or other nonspecific error. Possible failure reasons: Problems with the query, ResultSet property not set correctly, parameters not set correctly, or connection not established correctly.
    Task failed: Execute SQL Task 1
     
    the initial execute sql task where the dataset is selected works fine but it is within the foreach loop that it fails.
     
    any help gratefully recieved
     
     

    DB:2.39:Using User Defined Function In Execute Sql Task Within Foreach Loop mc

    Hi John
     
    thanks again fro yuo help - i found the error - I had a rogue carriage return in the update command of the final execute sql task that seemed to be causing the issue. When I removed it all was good.
     
    regards
     
    scott
     

  • RELEVANCY SCORE 2.39

    DB:2.39:Unexpected Return Value Of Omp_Get_Thread_Num() With Tasks 9s



    Hi,

    I'm using icc version 13.0.0 (gcc version 4.1.2 compatibility) on linux.

    I've created a simple example of a code I'm trying to use.

    Running this code using gcc -fopenmp seems ok, but with icc -openmp the program is stuck.

    With icc I get inconsistency with the thread numbers inside the for loop and inside the task_func() function.

    An example for the output:

    For loop: number of threads: 4

    For loop: New thread created, id = 0

    Enter task_func: omp_thread_num = 0

    For loop: New thread created, id = 1

    Enter task_func: omp_thread_num = 1

    For loop: New thread created, id = 3

    Enter task_func: omp_thread_num = 1

    For loop: New thread created, id = 2

    Enter task_func: omp_thread_num = 3

     (I get thread id 1 twice).

    Any idea what the problem is?

    Thanks,

    The code:

    #include iostream

    #include "omp.h"

    void task_func() {

        #pragma omp critical

        std::cout "Enter task_func: omp_thread_num = " omp_get_thread_num() "\n";

        #pragma omp barrier

    }

    int main () {

        int threads_cnt = atoi(getenv("OMP_NUM_THREADS"));

        int task_i;

        std::cout "For loop: number of threads: " threads_cnt "\n";

        #pragma omp parallel for

        for (task_i = 0 ; task_i threads_cnt ; task_i++) {

              #pragma omp critical

              {

              std::cout "For loop: New thread created, id = " omp_get_thread_num() "\n";

              }

              #pragma omp task

              task_func();

        }

    }

    DB:2.39:Unexpected Return Value Of Omp_Get_Thread_Num() With Tasks 9s


    Hi saineyl,

    From icc documentation: "When a thread encounters a task construct, a task is generated from the code for the associated structured block. The encountering thread may immediately execute the task, or defer its execution. In the latter case, any thread in the team may be assigned the task."  So, it is not guaranteed that each thread will get one task to work on.  Some threads may get one or more tasks, while others may get nothing.

    I added a "sleep(1);" before #pragma omp task.  Sometimes, I got "perfect" result, which is everybody gets a task.  Most cases, I got something similar to this:

    $ icpc -fopenmp t.cpp ./a.out

    For loop: number of threads: 8

    For loop: New thread created, id = 0

    For loop: New thread created, id = 1

    For loop: New thread created, id = 2

    For loop: New thread created, id = 3

    For loop: New thread created, id = 4

    For loop: New thread created, id = 5

    For loop: New thread created, id = 6

    For loop: New thread created, id = 7

    Enter task_func: omp_thread_num = 0

    Enter task_func: omp_thread_num = 1

    Enter task_func: omp_thread_num = 2

    Enter task_func: omp_thread_num = 3

    Enter task_func: omp_thread_num = 4

    Enter task_func: omp_thread_num = 2

    Enter task_func: omp_thread_num = 4

    Enter task_func: omp_thread_num = 0

    $

     

     This is absolutely fine.  You make your tasks big enough like this

        #pragma omp critical

        {

            std::cout "Enter task_func: omp_thread_num = " omp_get_thread_num() "\n";

            sleep(3);

        }

     

    You will always get "perfect" task assignment as you expected.

    Another thing to note is the barrier.  From the documentation: "Each thread that encounters this pragma must wait until all threads in the team have arrived. After the last thread of the team arrives, all threads are released and may continue execution of the enclosing parallel region."

    Since some threads might get nothing to work on, they will not go into the task_func() and will not hit #pragma omp barrier.  That would be a problem, and your program might hang for ever.

    Thanks.

  • RELEVANCY SCORE 2.39

    DB:2.39:Excel Source Cannot Find Sheet When Using Foreach Loop Container 9d


    I have SQL Server 2012 SSIS. I need help with Foreach Loop container.
    1) I have C:\\Excel\ folder and multiple Excel.xlsx files are stored there to be imported
    2) I have Foreach Loop Container
    -Foreach File Enumerator is selected
    -Expressions are empty
    -Folder is set as C:\\Excel\
    -Files is *.*
    -Variable is created. User::Filename, 0
    2) I have created variable FileName, String,0
    3) I have Excel Connection Manager
    -ExcelFilePath = @[User::FileName]
    4) I have data flow task with Excel Source and OLE DB Destination
    Error occured with Execute:
    [Excel Source [2]] Error: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E37.
    [Excel Source [2]] Error: Opening a rowset for SheetName$ failed. Check that the object exists in the database.

    Kenny_I

    DB:2.39:Excel Source Cannot Find Sheet When Using Foreach Loop Container 9d

    Hi Kenny_I,
    The issue occurs because you have not specified a valid value for the variable @FileName. The error persists even if we set the “DelayValidation” property of the Excel Connection Manager to True. After you assign a value like “C:\Excel\Test1.xlsx” (without
    quotes) to the variable, the package should work fine.
    Reference:
    http://www.bidn.com/blogs/mikedavis/ssis/625/loop-through-excel-file-in-ssis
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    hereMike Yin
    TechNet Community Support

  • RELEVANCY SCORE 2.39

    DB:2.39:How Can I Loop Over Lists Inside A List ? 1d


    public static ListListstring Threads = new ListListstring();

    After some code in the end this List contain 49 Lists in each List there are different number of indexs.
    How can i loop over each List in Threads and get from each List the text in each index but using For (int...
    Not foreach ?

    DB:2.39:How Can I Loop Over Lists Inside A List ? 1d

    If I understood your correctly then you need something like Threads[i].RemoveAt(j). Of course, when you remove things from a list you need to adjust the index - you know this from a previous thread. In fact the problem seems to be identical except for this
    ListListstring variation which doesn't change much:
    public static void CheckIfResponseContainWords() {
    for (int i = 0; i Threads.Count; i) {
    for (int j = Threads[i].Count - 1; j = 0; j--) {
    if (!WordsList.words.Any(w = Threads[i][j].Contains(w)) || Threads[i][j] == ) {
    Threads[i].RemoveAt(j);
    }
    }
    }
    }

    But it's all horrible complicated, you can and should simplify this by using foreach and RemoveAll:
    foreach (var thread in Threads)
    thread.RemoveAll(line = line == || !WordsList.words.Any(w = line.Contains(w)));

  • RELEVANCY SCORE 2.39

    DB:2.39:Slow Web Service Task In Foreach Loop 71


     
    Hi I have created a web service task that sits inside of a foreach loop.  The loop is a ado enumerator.  This loop is going to loop through about 35,000 records and make 35,000 web service calls. 
     
    So far through my testing, I have gotten it to read and write everything correctly, but each call to the web service takes about 1-2 seconds and maxes out the CPU.  This would take almost all day for this web service to run at 100% CPU power all day.  We want to be able to run this a few times a day or at least once a day.
     
    I have disabled all of the other tasks in the foreach loop so it just calls the web service task and found that it's the web service task that takes up 100% of the CPU and takes 1-2 seconds to run.  I have also tried creating a mock web service on the server that just sends back the same mock data, so it's extremely fast, but the Web Service Task still maxes out the CPU and takes 1-2 seconds per call.
     
    I have tried this out on 2 different servers, all with a few gigs of ram they're not using.  It seems more like it's a CPU thing, or that the Web Service Task has a high overhead that each time in the loop it takes 1-2 seconds to create the task.
     
    Anyone have any advice?
     
    Thanks,
    -Will

    DB:2.39:Slow Web Service Task In Foreach Loop 71

    instead of processing all 35,000 records at once, can you break it down into smaller batches of 5,000 or so?  it seems like your box is choking on processing all those rows in one batch.
     
    hth

  • RELEVANCY SCORE 2.38

    DB:2.38:Ray Hitting Any Object With Tag In C# 8c



    enclose the if(hit.collider.gameObject == target) inside of a loop over all the objects in the list.

    if(hit.collider.gameObject == target){
    //inside work
    }


    becomes

    foreach(GameObject obj in targets){ // using targets because it makes more sense for a plural
    if(hit.collider.gameObject == obj){
    // inside work
    }
    }


    this way you can just walk through the list as needed

    DB:2.38:Ray Hitting Any Object With Tag In C# 8c


    enclose the if(hit.collider.gameObject == target) inside of a loop over all the objects in the list.

    if(hit.collider.gameObject == target){
    //inside work
    }


    becomes

    foreach(GameObject obj in targets){ // using targets because it makes more sense for a plural
    if(hit.collider.gameObject == obj){
    // inside work
    }
    }


    this way you can just walk through the list as needed

  • RELEVANCY SCORE 2.38

    DB:2.38:Error 0x800a0bcd In A Foreach Loop Container zz


    Hi
    I ve two nested foreach loop containers, all tasks included inside run well but when i launch the package i meet a error :

    0x800A0BCD to the output of
    the internal foreach loop container
    How to see what happens wrong and how to solve this issue ?
    Thx

    DB:2.38:Error 0x800a0bcd In A Foreach Loop Container zz

    That would be the the unmanaged code (presumably the C DLL that handles the memory buffers), the memory buffer simply cannot handle parallel loads.Arthur My Blog

  • RELEVANCY SCORE 2.38

    DB:2.38:Basic C# Logic pm


    hi all
    i am having 2 for each loop,one inside one. i am getting data from list, in foreach i have to get first element of the list and den move to second foreach loop and get the first element, again i move to 1st foreach and get second element, den 2nd
    foreach 2nd element and so on.
    ex:
    foreach(String data from list1)
    {
    foreach(String data from list2)
    {}
    }

    please advice me!!

    DB:2.38:Basic C# Logic pm

    Hi,
    I would even consider changing the datastructure used. The 2 seperate lists are not really good when your key intention is to store a pair of values.
    In case you see it as a Key - Value relationship, then a dictionary would be a good solution. Or if you just want to store pairs, you could create your own type or just use the Tuple class (http://msdn.microsoft.com/en-us/library/system.tuple.aspx)
    With kind regards,
    Konrad

  • RELEVANCY SCORE 2.38

    DB:2.38:Problem With Event Handlers k8


    I have a package with ForEach Loop Container. In that ForEach Loop Container I have a Script Task which is connected to Data Flow Task. I created events handlers for Scritp Task and Data Flow Task on OnError event. Even the Script Task is failed OnError
    event handler is not firing. Please help me.

    DB:2.38:Problem With Event Handlers k8

    Lol.....
    Thanks much for all your help.

  • RELEVANCY SCORE 2.38

    DB:2.38:Ip - Trying To Better Understand Foreach In Refdata fp



    Hi,

    We would like to implement a copy function to copy actual data to plan (multi-provider). I know I'll need to use FOREACH IN REFDATA but I would like to better understand it.

    If you use FOREACH IN REFDATA, will this loop over your reference data within each block of your plandata? For example if you have only two combinations in your plan data, will it then loop twice over the entire reference data (with the characteristics in the foreach in refdata loop)?

    Will the FOREACH IN REFDATA also work even if you have no planning data at yet created?

    = we would like the budget process to start with a copy of actual data (to default data, but also to generate the most important combinations). We cannot use standard copy because there are some special items to be taken into account.

    regards

    D

    DB:2.38:Ip - Trying To Better Understand Foreach In Refdata fp


    Hi,

    I solved it myself. foreach in selection should be used ... since foreach in refdata only starts from what is in your plandata.

    D

  • RELEVANCY SCORE 2.38

    DB:2.38:How To Check Out Eof Inside A Foreach Loop Container? 9c


    Hi everyone,
    I've got a Foreach loop container which uses a Foreach ADO Enumerator and works fine.
    But problem comes when I launch inside the general loop another Sql Task (select) which sometimes has rows and sometimes hasn't. When it have rows everything is fine the workflow follows fine but when it has not.
     
    I obtain this error (obvioulsy)
     
    [Execute SQL Task] Error: An error occurred while assigning a value to variable GZon: Single Row result set is specified, but no rows were returned..
     
    How to deal with that?
     
    Thanks indeed

    DB:2.38:How To Check Out Eof Inside A Foreach Loop Container? 9c

     enric vives wrote:

    Although as a colleague of mine commented another solution could be do a SELECT COUNT(*) from... before the SELECT and see if it returns 0 or 1.

  • RELEVANCY SCORE 2.38

    DB:2.38:Berkeley Db Dynamic Reffernece? fj


    Greetings my first post here.

    I am using Perl ,

    I have about 20 Berkley db's that I have created, all hashes , and all named alphabetically %A %B %C %D .

    I want to use a foreach loop to pull from a array of the db names
    my @table = qw(A B C D);

    and I want to do an insert, into the dbs inside the loop dynamically based on the array.

    foreach $db(@table) { ....

    $$db{"$key"} = "$value" ; # --- where I am stuck

    above syntax does not work tho, can anyone help me with the right way to do this, specifically reference a BDB hash dynamically?

    thanks in advanced

    DB:2.38:Berkeley Db Dynamic Reffernece? fj

    Greetings my first post here.

    I am using Perl ,

    I have about 20 Berkley db's that I have created, all hashes , and all named alphabetically %A %B %C %D .

    I want to use a foreach loop to pull from a array of the db names
    my @table = qw(A B C D);

    and I want to do an insert, into the dbs inside the loop dynamically based on the array.

    foreach $db(@table) { ....

    $$db{"$key"} = "$value" ; # --- where I am stuck

    above syntax does not work tho, can anyone help me with the right way to do this, specifically reference a BDB hash dynamically?

    thanks in advanced

  • RELEVANCY SCORE 2.38

    DB:2.38:Foreach Loop Container Failed To Traverse Through All Files In A Folder kx



    I have one temp folder C:\Mydata inside that i have .csv files with name
    demo1.csv demo2.csv...etc
    Now I want to insert data from all those files into database table
    for this I have taken Foreach Loop Container in the property
    Directory I mention C:\Mydata inside Foreach Loop Container taken a
    Data Flow Task in that Flat File Source is there in the connection manager property in
    file name what should I mention, so that it will traverse through all folder and all files whose extension is
    .csv I did like C:\DEMO\*.csv which is giving me error :
    no file found path is wrong

    DB:2.38:Foreach Loop Container Failed To Traverse Through All Files In A Folder kx

    Fill in a random file and overwrite it with an expression.
    Check this example:
    http://microsoft-ssis.blogspot.com/2011/02/how-to-configure-foreach-loop-file.html
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com

  • RELEVANCY SCORE 2.38

    DB:2.38:Loop Through Partially Filled Array Of Objects 3f



    just insert a line like this at the start of the loop:

    for(int i = 0; i array.Length; i++) {
    if(array[i] == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    or, with a foreach loop:

    foreach(GameObject go in array) {
    if(go == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    This will skip all the following code inside the loop and go on with the next array element.

    DB:2.38:Loop Through Partially Filled Array Of Objects 3f


    If you're using C# you could use a HashSet. It both allows you to do a foreach, and also to Add and Remove elements with reasonable speed. An array is probably not the best choice for something which grows and shrinks dynamically.

  • RELEVANCY SCORE 2.37

    DB:2.37:Foreach File Enumarator Inside Foreach Ado Numarator Doesnt Work ax


    Hi,I have a foreach ADO enumarator which returns each D_IDs. Now inside that loop I have another foreach FILE enumarator which needs to go to a folder(Directory is geneated from D_ID) and itterates through each files inside it and move it. My ADO loops works fine but File loop just doing nothing.What am I missing here.Thanks for all your help.

    DB:2.37:Foreach File Enumarator Inside Foreach Ado Numarator Doesnt Work ax

    never mind it worked. D_ID(16)  had white space. Resulting D_ID had 13 char so it was looking for a file in the folder c:\1234567891234    \instead of C:\1234567891234\Thanks.

  • RELEVANCY SCORE 2.37

    DB:2.37:Looping Issue With For Each... kj


    I have pkg that has 2 foreach task. One inside another....loop within a loop...So before the first foreach I have a script tasks that populates a variable NumList then I have a SQL execute that ppopulates a variable LetterList...I do this outside the loops because the list values don't change....so instead of calling the sql execute with the Numlist loop I do it outside since the LetterList is going to contain the same values for all the items in the NumList...Now I connect to the foreach and the first foreach loops thru the NumListthen inside that foreach I have another foreach that loops thru the LetterList...NumList             LetterList1                       A2                       B3                       CI want to be able to loop thru 1-3 and for each number I want to loop thru A-C so. 1 a,b,c, ...2 a,b,c.....3 a,b,c.....If the NumList contains only on item in the list then it works but once the NumList has more then 1 item I get an error trying to loop thru the LetterList.It seems once I loop thru the LetterList I have to repopulate it or something cause the Foreach task complains about the As I loop thru the LetterList I'm assigning variables in the variable mapping of the foreach..The type of the value being assigned to variable User::.... differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

    DB:2.37:Looping Issue With For Each... kj

    Here's a possibility for you then - if you're still interested in getting them into one loop.Run your Execute SQL Task to retrieve the LetterList into an object variable first.  Then in your Script Task, add that variable in its ReadOnly list.  Your Script Task already has another variable in it's ReadWrite list - for putting your Web Service response into, right?So, inside your Script Task, continue to fetch the Web Service information.  But don't just write that to your variable...Instead, Create a new (third) recordset inside your Script, containing all of the columns of your LetterList table and NumberList web service recordsets (the joined set of columns).  Now loop inside your Script, adding joined rows to the new recordset.  In effect, you're doing the join.Pass out that third recordset by assigning it to your read/write variable.  Now you only need one loop.It's more complicated, and very optional, but it does get rid of one loop and multiple requeries of your table.

  • RELEVANCY SCORE 2.37

    DB:2.37:Mkl Performance Issue mx



    I have been running an MKL DGEMM benchmark in native mode on a KNC card, but have noticed strange behavior.  The performance is inconsistent and varies quite a bit.  I tried multiple thread affinity settings and noticed the same behavior with varying numbers of threads and threads per core.  The test consists of calling DGEMM for a set of 6,000 by 6,000 matrices a total of 1,000 times so I can compare calls.  During my testing the performance varied by as much as 100 GFLOPS.  A Google search did not reveal much.  However, I did find a Dr. Dobb's article that noted the unusual behavior and attributed it to OS jitter, but did not ellaborate.  Has anyone else noticed this behavior?

    DB:2.37:Mkl Performance Issue mx


    Thank you for the explanation of 4K aliasing. It was very informative.

    Yes, I had already read that section of the MPSS release notes. However, I thought it would not be applicable to my situation because I do not call the timer function from within a parallel region. In fact, I have no OpenMP directives within the code. The gettimeofday() calls surround the call to the multi-threaded MKL DGEMM routine. Given my understanding of how OpenMP typically works, I would assume the threading environment is not initialized until the dgemm_() function call and is done so internally by MKL, but I could be mistaken. Also, I have not had this issue with a multi-threaded matrix-matrix multiplication code I wrote using OpenMP. I have consistently gotten similar results using both clock sources and have not seen the same difference.

  • RELEVANCY SCORE 2.37

    DB:2.37:Cmdlet In Foreach Loop Errors And Then Breaks Out Of Loop jx


    I am running a command inside of a foreach loop. The command sometimes fails. I have set EA to stop and am using a try catch, but the first time the command fails, it breaks out of the loop. I need the loop to continue until all processing has been done.
    I thought that with EA set to stop and using a try catch, that the loop would continue.
    foreach($Item in $Params){
    try{
    Set-ADUser $UserName -replace $Item -ErrorAction 'Stop' -ErrorVariable Errval
    Log $ModifyUserLog Modified $Item for User object : $UserName
    }
    Catch{
    Log $ModifyUserLog Error processing $Item. The error was $Errval
    }
    }

    DB:2.37:Cmdlet In Foreach Loop Errors And Then Breaks Out Of Loop jx

    You can also call GetEnumerator on the hashtable. This will perform slightly better, but not so much that you'd notice. It's mostly which one you prefer aesthetically:
    foreach($Item in $Params.GetEnumerator()) {
    try {
    Set-ADUser $UserName -replace @{ $Item.Key = $Item.Value } -ErrorAction 'Stop' -ErrorVariable Errval
    Log $ModifyUserLog Modified $(Item.Key) for User object : $UserName
    } Catch {
    Log $ModifyUserLog Error processing $(Item.Key). The error was $Errval
    }
    }

  • RELEVANCY SCORE 2.37

    DB:2.37:Sequence Behavior zm


    Hi All,

    I have come across one strange behavior of sequence in Oracle 11g R2. Could anyone please account for the change. I have posted the simulation scripts as below.

    ----Created a new sequence------
    CREATE TABLE JO_SEQ_TEST (A NUMBER);

    ----Created a new table------
    CREATE SEQUENCE JO_sEQ_1 START WITH 1;

    ----Populating the table with the sequence values------

    DECLARE
    M NUMBER;
    BEGIN
    FOR I IN 1..10
    LOOP
    DBMS_OUTPUT.PUT_LINE('Loop Count:'||TO_CHAR(i));
    INSERT INTO JO_sEQ_TEST VALUES (JO_SEQ_1.NEXTVAL) RETURNING A INTO M;
    DBMS_OUTPUT.PUT_LINE('Inserted value:'||TO_CHAR(M));
    END LOOP;
    END;

    ---block output-------
    Loop Count:1
    Inserted value:2
    Loop Count:2
    Inserted value:3
    Loop Count:3
    Inserted value:4
    Loop Count:4
    Inserted value:5
    Loop Count:5
    Inserted value:6
    Loop Count:6
    Inserted value:7
    Loop Count:7
    Inserted value:8
    Loop Count:8
    Inserted value:9
    Loop Count:9
    Inserted value:10
    Loop Count:10
    Inserted value:11

    SELECT * FROM JO_SEQ_TEST;

    2
    3
    4
    5
    6
    7
    8
    9
    10
    11My question is that why the records are inserted starting with 2, and not with 1. How the sequence value 1 is missing during insertion?
    If I try with alternative way, by holding the sequence value in another local variable, then inserting into the table, it works fine. Like below

    ---------after recreating the table and sequence------------

    DECLARE
    M NUMBER;
    BEGIN
    FOR I IN 1..10
    LOOP
    DBMS_OUTPUT.PUT_LINE('Loop Count:'||TO_CHAR(i));
    M:= JO_SEQ_1.NEXTVAL;
    INSERT INTO JO_sEQ_TEST VALUES (M);
    DBMS_OUTPUT.PUT_LINE('Inserted value:'||TO_CHAR(M));
    END LOOP;
    END;

    ----block output-------
    Loop Count:1
    Inserted value:1
    Loop Count:2
    Inserted value:2
    Loop Count:3
    Inserted value:3
    Loop Count:4
    Inserted value:4
    Loop Count:5
    Inserted value:5
    Loop Count:6
    Inserted value:6
    Loop Count:7
    Inserted value:7
    Loop Count:8
    Inserted value:8
    Loop Count:9
    Inserted value:9
    Loop Count:10
    Inserted value:10

    DB:2.37:Sequence Behavior zm

    It appears that this is documented behavior:

    http://stackoverflow.com/questions/4153807/oracle-sequence-starting-with-2-instead-of-1

    (google rocks).

  • RELEVANCY SCORE 2.37

    DB:2.37:Problem With Containers 7c


    I have created a project and wanted to put the steps into a ForEach Loop. I add the ForEach Loop container and I can see the properties. I put my tasks inside and then format the ForEach Loop. As soon as I edit it, I can no longer
    see the properties of the ForEach Loop container. I also cannot delete any tasks inside or add any or delete the ForEach Loop container getting an Error
    TITLE: Microsoft Visual Studio
    ------------------------------
    Exception from HRESULT: 0xC0010014
    ------------------------------
    ADDITIONAL INFORMATION:
    Exception from HRESULT: 0xC0010014 (Microsoft.SqlServer.DTSRuntimeWrap)
    ------------------------------
    BUTTONS:
    OK
    ------------------------------

    Does anyone have any ideas? I am running SQL SERVER 2005 SP3 on a x64 machine.

    DB:2.37:Problem With Containers 7c

    I would like to uninstall SSIS again and reinstall it. From add or replace programs I click on intergration services, is this all I need to remove? I also have 2 microsoft c programs, do those need to be uninstalled as well? Also does BIDS
    get uninstalled with the Integration services?

    Thanks

  • RELEVANCY SCORE 2.37

    DB:2.37:Showing String Length In Foreach 3f


    I would like to show the length of each string inside the foreach loop. However, I get error with the following code. How can I do that? Thanks.

    %@ taglib uri="http://java.sun.com/jsp/jstl/core_rt" prefix="c" %

    c:set var="strs" value="Peter, Paul, Mary" scope="page" /

    c:forEach var="str" items="${pageScope.strs}"
    c:out value="${str.length()}"/
    /c:forEach

    DB:2.37:Showing String Length In Foreach 3f

    Oops, you are right. I am using that URI because I am using the Jarkarta Standard Taglib which is an implementation of JSP Standard Taglib.

    http://jakarta.apache.org/taglibs/doc/standard-doc/GettingStarted.html

    I am also wondering why RT version of that taglib can resolve those expressions. I have to take a look later. Thanks anyway.

  • RELEVANCY SCORE 2.37

    DB:2.37:Im Trying To Use Foreach To Loop Throught Lables Controls In My Form But Its Never Get Inside The Loop sf



    foreach (Control lb in this.gridView2.Controls.OfTypeLabel())
    {
    if (lb.Controls.Count = 15)
    {
    lb.Visible = false;
    }
    }

  • RELEVANCY SCORE 2.36

    DB:2.36:Foreach Enumerator Cannot Enumerate dj


    Hello,I've created simple SSIS package based on:http://www.sqlservercentral.com/articles/Analysis+Services/63382/It works great from Business Intelligence Studio, but doesn't work from SQL Agent Job--------------Microsoft (R) SQL Server Execute Package Utility  Version 9.00.3042.00 for 32-bit  Copyright  Code: 0xC0014023     Source: Foreach Loop Container      Description: The GetEnumerator method of the ForEach Enumerator has failed with error 0x80004005 Unspecified error. This occurs when the ForEach Enumerator cannot enumerate.  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  --------------SQL 2005 SP2 x86

    DB:2.36:Foreach Enumerator Cannot Enumerate dj

    Hello,Relay thanks for answer, I don't believe I've changed SQL Agent Account, restart Agent and SSIS package start works. Great! Thanks!

  • RELEVANCY SCORE 2.36

    DB:2.36:Lv7.1 - Property Node Inside A Loop - Bug Or Feature? ck



    Using LV7.1,I tried to create a property node for a front panel control that was located within a loop on the block diagram. The resulting node had a shadow outline and I couldn't move it at all. However, when I moved the control outside the loop and created the node there, I could move both back inside the loop without any problems. I duplicated this behavior with several different (simple) test programs, so it wasn't particular to my VI. Is this a case of LV trying to "tell me something", or was this a known issue within 7.1?

    Thanks.

    Michael Tracy

    Synergy Microwave







    Solved!
    Go to Solution.

    DB:2.36:Lv7.1 - Property Node Inside A Loop - Bug Or Feature? ck


    After more fiddling with this, I finally discovered that it was a simple user (e.g., nut-behind-the-wheel) error. I kept trying to select the floating node using the outline select feature and that wouldn't work, but when I carefully placed the mouse on top of it, I managed the click-and-drag move, no problem. Oh well, live and learn!

    Michael

  • RELEVANCY SCORE 2.36

    DB:2.36:Accessviolationexception When Invoking Workflowinvoker.Invoke 8j



    I'm trying to run a parallel foreach loop with 32 threads.

    This foreach loop is calling a:
    WorkflowInvoker.Invoke(new MyWorkflow(), myInputDictionary)

    The parallel foreach loop consists of a list of around 65000 items.

    At some point, at around 6000 - 6700 items the invocation of WorkflowInvoker.Invoke(new MyWorkflow(), myInputDictionary) throws an AccessViolationException with the message: Attempted to read or write protected memory. This is often an indication that other
    memory is corrupt.

    I have tried different things, like creating an instance of the WorkflowInvoker and passing an instance of MyWorkflow directly to the newly created WorkflowInvoker and then calling the Invoke method on the class. Also just calling the WorkflowInvoker.Invoke
    as a static method, but it doesn't make a difference. The application crashes at the same point every time. Because of the threads it's hard to debug and pinpoint exactly what is causing the trouble.

    Of course the problems doesn't occur if I'm doing the calls in a normal foreach loop.

    At first we thought the virtual machine was running low on memory, because the application started eating all available memory until it reached a limit of 85% of the total memory (4GB) and then it seemed to crash. So we changed the memory size to 1GB, to see
    if we could induce the exception earlier in the loop, but instead Windows started garbagecollecting, so in the end the exception still occured at the same point around 6000 - 6700 items.

    Any suggestions as to what should be my next move, is much appreciated ;-)

    This question has also been posted on StackOverflow, but with no luck atm.

    On a side-note, we have also tried to run the Parallel.ForEach with 64, 16 and 2 threads. All crashes at around 6000 - 6700 items.

    Also we have tried with the same data in each item in the list, so to be sure, that it was not a specific item in the list that crashes the application. It didn't make a difference, however.

    Link to the SO thread:http://stackoverflow.com/questions/12283360/accessviolationexception-when-calling-workflowinvoker-invoke

    DB:2.36:Accessviolationexception When Invoking Workflowinvoker.Invoke 8j


    I'm trying to run a parallel foreach loop with 32 threads.

    This foreach loop is calling a:
    WorkflowInvoker.Invoke(new MyWorkflow(), myInputDictionary)

    The parallel foreach loop consists of a list of around 65000 items.

    At some point, at around 6000 - 6700 items the invocation of WorkflowInvoker.Invoke(new MyWorkflow(), myInputDictionary) throws an AccessViolationException with the message: Attempted to read or write protected memory. This is often an indication that other
    memory is corrupt.

    I have tried different things, like creating an instance of the WorkflowInvoker and passing an instance of MyWorkflow directly to the newly created WorkflowInvoker and then calling the Invoke method on the class. Also just calling the WorkflowInvoker.Invoke
    as a static method, but it doesn't make a difference. The application crashes at the same point every time. Because of the threads it's hard to debug and pinpoint exactly what is causing the trouble.

    Of course the problems doesn't occur if I'm doing the calls in a normal foreach loop.

    At first we thought the virtual machine was running low on memory, because the application started eating all available memory until it reached a limit of 85% of the total memory (4GB) and then it seemed to crash. So we changed the memory size to 1GB, to see
    if we could induce the exception earlier in the loop, but instead Windows started garbagecollecting, so in the end the exception still occured at the same point around 6000 - 6700 items.

    Any suggestions as to what should be my next move, is much appreciated ;-)

    This question has also been posted on StackOverflow, but with no luck atm.

    On a side-note, we have also tried to run the Parallel.ForEach with 64, 16 and 2 threads. All crashes at around 6000 - 6700 items.

    Also we have tried with the same data in each item in the list, so to be sure, that it was not a specific item in the list that crashes the application. It didn't make a difference, however.

    Link to the SO thread:http://stackoverflow.com/questions/12283360/accessviolationexception-when-calling-workflowinvoker-invoke

  • RELEVANCY SCORE 2.36

    DB:2.36:Querying Random Number Of Elements, Linq s1


     
    I'm outputting one element of an XML document to a windows form using LinQ in C# (2008 ve beta) and I'm having trouble with there being a random number of elements.  For example here is the document.xml outline
     

    [...]

     
    [...] random number of [...]
     

    [...]

    [...]

     
    I've built the code to display everything but the ingredients, displayed below.  I think I will have to next a foreach loop inside my current foreach loop to do this but the syntax I've tried has all been deadends.  Does anybody have any experience with this in Linq?
     

    Code Block

    DB:2.36:Querying Random Number Of Elements, Linq s1

     jrboddie wrote:

    The following method performs a Linq query on the ‘cookbook’ xml element to extract the recipe with a specified ‘name’ value.  The ‘ingredient’ elements are output to a textbox.  (You should be able to change this to labels if you like.)
     
            private void GetRecipe(XElement cookbook, string nameToFind)
            {
                IEnumerableXElement query =
                    from recipe in cookbook.Elements()
                    where recipe.Elements().Any(name = name.Value == nameToFind)
                    select recipe;
     
                foreach (XElement el in query.Descendants().Elements(ingredient))
                {
                    string amount = el.Element(amount).Value.ToString();
                    string measure = el.Element(measurement).Value.ToString();
                    string item = el.Element(item).Value.ToString();
                    textBox1.AppendText(amount +   + measure +    + item + Environment.NewLine);
                }
            }
     
    By the way, I am assuming that each ingredient has the tag ‘ingredient’ instead of ‘ingredient1’, ‘ingredient2’ etc.
     

  • RELEVANCY SCORE 2.36

    DB:2.36:Unable To Fetch List Items In Event Receiver 8m


    Hi,
    // Get a reference to the site collection.
    SPSite site = properties.OpenSite();

    // Get a reference to the root site.
    SPWeb rootWeb = site.RootWeb;

    // Get the announcement list on the root site.
    SPList rootList = rootWeb.Lists[EmailConfigList];
    foreach (SPListItem item in rootList.Items)
    {
    from = item[Title].ToString();
    }

    I have created an event reciever for SP2013 for item added event. Here I am trying to fetch details from another custom list in sharepoint. But it is not going inside the for-each loop. The immediate window for the list shows that ItemCount=19 , i.e. there
    are 19 items. But the Items.Count gives 0. I have enclosed the above in SpSecurity.Runwithelevated priveleges. Kindly help as it is not going inside the foreach loop.

    DB:2.36:Unable To Fetch List Items In Event Receiver 8m

    Jerry, Same issue I have faced for list Item event receiver.
    propertries.listitem was null but in quick watch I was able to get Item ID. I have resolved this by updating list schema.

  • RELEVANCY SCORE 2.36

    DB:2.36:Foreach Loop Container Does Not Iterate Automatically s8


    Hi,
     
    Another classic example of something silly I must be doing
     
    I have a Foreach Loop Container which uses a Foreach ADO Enumerator.
    The object source is a recordset variable.
     
    Inside the Foreach Loop Container, a lot of things are happening - some Execute SQL Tasks, Send Mail Tasks, Script Tasks and also a couple of Sequence Containers.
     
    Now, I am getting 2 records in the recordset, but, the Foreach Loop Container executes just once.
     
    Any Ideas?
     
     
    Thanks in advance.
    Regards,
    B@ns

    DB:2.36:Foreach Loop Container Does Not Iterate Automatically s8

    Hi,
     
    Well, I didn't do much and the Foreach Loop Container is working now. It is indeed looping through all the available records.
     
    No clue as to why and how.
    Thanks for replying!
     
    Regards,
    B@ns
     
     

  • RELEVANCY SCORE 2.36

    DB:2.36:Using Foreach Loop Container With File System Task To Rename And Move Files x9


    the foreach loop container will not rename and move files for me

    sukai

  • RELEVANCY SCORE 2.36

    DB:2.36:Ado.Net Schema Rowset Enumerator, What Is The Index Number For...? 9s


    These steps tell you how to set up a foreach loop to go thru worksheets within an excel file.Step 7 is where you save the current sheet name to a package variable. It says to map Index 2.Is there another Index number that holds the position number of the current worksheet?
    1. Create an ADO.NET connection manager that uses the Microsoft Jet OLE DB Provider to connect to an Excel workbook. On the All page of the Connection Manager dialog box, make sure that you enter Excel 8.0 as the value of the Extended Properties property.2. Create a string variable that will receive the name of the current table on each iteration of the loop.3. Add a Foreach Loop container to the Control Flow tab. For information on configuring the ForeachLoop, see How to: Configure a Foreach Loop Container.4. On the Collection page of the Foreach Loop Editor, select the Foreach ADO.NET Schema Rowset enumerator.5. As the value of Connection, select the ADO.NET connection manager that you created previously.6. As the value of Schema, select Tables.Note   The list of tables in an Excel workbook includes both worksheets (which have the $ suffix) and named ranges. If you have to filter the list for only worksheets or only named ranges, you may have to write custom code in a Script task for this purpose. For more information, see Working with Excel Files with the Script Taskb8fa110a-2c9c-4f5a-8fe1-305555640e44.7. On the Variable Mappings page, map Index 2 to the string variable created earlier to hold the name of the current table.8. Close the Foreach Loop Editor.9. Create tasks within the Foreach Loop container that use the Excel connection manager to perform the same operations on each Excel table in the specified workbook.

    DB:2.36:Ado.Net Schema Rowset Enumerator, What Is The Index Number For...? 9s

    This is the complete map:

    Only index 2 (TABLE_NAME) is useful for
    looping through excel worksheets.Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • RELEVANCY SCORE 2.36

    DB:2.36:Using Return In A Foreach Statement xd


    Hello,
    I faced a strange (somehow resolved) problem with an exception being thrown without much explanations. I'd like to know if someone can point me to the article or specification talking of this behavior, since I didn't find anything yet and am pretty curious about it.
    I was messing around with the NETCF2 PocketOulook API and wrote a simple method to retrieve a PimItem in a collection given an itemId which looked like this:
    public PimItem GetItem(PimItemCollection collection, int itemId) {    foreach (PimItem item in collection) {        int iId = int.Parse(item.ItemId.ToString());        if (iId == itemId) return item;    }    return null;}
    When the itemId was correct for the collection and the corresponding PimItem was found, if I tried to later update it using the PimItem.Update() method, I kept getting the following exception: InvalidOperationException: Can't modify the item collection inside a foreach statement. I first thought I had put my Update() call within such a statement. However after spending lots of time debugging my application (my actual code is much more complicated), this was definitely not the case. I then started hunting for every foreach statement I had used even if it had no obvious link with my Update() problem.
    It appeared that changing the code of my GetItem() function to something a bit less return-breaking-loop-dirty, the exception would not be thrown:
    public PimItem GetItem(PimItemCollection collection, int itemId) {    int i = 0;    PimItem rItem = null;    while(i collection.Count rItem == null) {         int iId = int.Parse(collection[ i ].ItemId.ToString());        if (iId == itemId) {            rItem = collection[ i ];        }        i++;    }    return rItem;}
    With this new implementation, everything works correctly, and the same Update() call I used on my returned PimItem does not throw that InvalidOperationException anymore.
    Fine, but still, can someone tell my why returning the item within the foreach loop would throw such an exception?
    According to the MSDN library, various articles on the web and even the C# Ecma-334 specification §15.8.4, I understood (correct me if I'm wrong) that the foreach CIL conversion should include some kind of finally statement where the hidden IEnumerator object used to loop on the collection is disposed. I have the (very strange) feeling that using a return statement while iterating on a PimItemCollection with the foreach keyword ignores the disposal of this enumerator, thus preventing the manipulation of the collection and its items.
    Could someone explain this to me (or negate my finally statement not being executed theory)?

    DB:2.36:Using Return In A Foreach Statement xd


    That sounds like a bug in enumerator implementation. Please file a bug report on connect.microsoft.com. Please attach simple project to reproduce the issue and describe expected and actual behavior. Also please specify the issue is in Windows Mobile (this assembly is not a part of NETCF) so it would be routed to appropriate team.
     

  • RELEVANCY SCORE 2.36

    DB:2.36:Unusual Problem With Xpath sz


    Hi :), I have an xpath expression for an xelement. When i run it in a wpf windows class it works and if i put it inside an abstract clasds that ive created with all the same references it doesnt work. Help? Regards Q

    DB:2.36:Unusual Problem With Xpath sz

    Hi QuddusAli,Based on my understanding, what you want is to remove a x element from its root, and you may do this in a self defined class method, but it doesnt work. But when you do this in a window class, it works ok. If Im off base, please feel free to let me know.I have tested that on my side, and it works as expected. I think the reference of the root x element is not the one where the removed x element get from. So, after a node removed the root still with no change.

    Here is the sample which I have tested on my side and works ok: public partial class XElementDemo : Window
    {
    public XElementDemo()
    {
    InitializeComponent();
    }

    private void Button_Click(object sender, RoutedEventArgs e)
    {
    System.Xml.Linq.XElement xelement = System.Xml.Linq.XElement.Load(XMLFile.xml);
    Class1 c = new Class1();

    System.Xml.Linq.XElement xe = c.GetXPath(xelement, //Transform3DGroup);
    System.Xml.Linq.XElement parent = xe.Parent;
    xe.Remove();
    MessageBox.Show(xelement.ToString());
    }
    }

    class Class1
    {
    public System.Xml.Linq.XElement GetXPath(System.Xml.Linq.XElement parent, string xPath)
    {
    System.Xml.Linq.XElement xe = System.Xml.XPath.Extensions.XPathSelectElement(parent, xPath);
    return xe;
    }
    }

    Hope this helps.If you still have any question about this issue, please feel free to let me know.Best regards,
    Linda LiuPlease remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.

  • RELEVANCY SCORE 2.36

    DB:2.36:Problem To Use Multiple Timers With Multiple Intervals Within My Code. dk


    Hi
    i'm facing problem in my code, when i want to create multiple timers (each timer has a different interval) to do some works. because i created each timer within foreach loop, i add timer_tick event handler like this :

    foreach (EmailManagementDataSet.ServersRow server in selectedServers)

    {

    Timer timer = new Timer();

    timer.Interval = server.TimerTick;

    timer.Tag = server.SmtpServer;

    timer.Tick = new EventHandler(timer_Tick);

    }

    DB:2.36:Problem To Use Multiple Timers With Multiple Intervals Within My Code. dk

    Thanks everybody.http://www.codeproject.com/KB/codegen/DatabaseHelper.aspx

  • RELEVANCY SCORE 2.35

    DB:2.35:Advise Please On The Foreach Statement The Foreach-Object Cmdlet And The Continue Statement. mf


    Hello All,
    Can someone please help me with the following question (I need to gain a clear understanding of what is happening here), thanks in advance.
    the outcome of the continue statement is difference when using the foreach statement or the foreach-object cmdlet, as follows:
    The first block of code executes as I would expect outputting numbers 1,2,3,4,6,7,8,9 and 10 to the console

    $numbers = $null
    $numbers = @(1..10)
    cls
    foreach ($number in $numbers) {

    if ($number -eq 5){continue}else{Write-Host $number}
    }

    However the second block of code (using the foreach-object cmdlet) outputs numbers 1,2,3 and 4 only, also it does not output ernie to the console, which appears to show no further processing (i.e. in case it exited the loop and continued to the next line
    in the script).
    $numbers | foreach {

    if ($_ -eq 5){continue}else{Write-Host $_}

    }
    Write-Host ernie
    I believe the main difference between the foreach statement in the first example and the foreach-object cmdlet in the second example is the foreach-object cmdlet basically pauses the pipeline until all objects are received (e.g. 10 array elements in this
    case), first off is that correct?
    Can someone please explain the above behavior to me please, for example why does it not also output 1,2,3,4,6,7,8,9 and 10? or at least output ernie as I thought perhaps the second example rather than going to the top of the loop might be exiting
    the loop.
    I am using PowerShell v2

    Thanks all
    Ernie

    DB:2.35:Advise Please On The Foreach Statement The Foreach-Object Cmdlet And The Continue Statement. mf

    $foreach.movenext() moves current item ($_) to next item
    this method is invoked after each loop

    #1 loop:
    do what is in that loop
    $foreach.movenext()
    goto #1

    so your case looks like this
    1. step in ($_ = 5)
    2. check if ($_ -eq 5)
    3. $foreach.movenext() ($_ = 6)
    4. foreach.movenext() ($_ = 7)
    5. goto 1.

  • RELEVANCY SCORE 2.35

    DB:2.35:Foreach Loop Container Missing Foreach File Enumerator cp


    I am currently working with BIDS 2008.  Would like to loop through a series of files in a directory, however when I go to use the ForEach Loop I seem to be missing the Foreach File Enumerator.  Am I missing something? SQL - new guy

    DB:2.35:Foreach Loop Container Missing Foreach File Enumerator cp

    Re-registred dll...........did not work.  Looks like there is no alternative but to repair................SQL - new guy

  • RELEVANCY SCORE 2.35

    DB:2.35:Foreach sd


    Hi I have created a ForEach loop based on a custom collection of 1 column containing string values (a list of table names).I want to loop thru this and save the row value (Table Name) into a user variable that will then be used to lookup the table name from within my data task, which is inside the loop.anyone know how to do this?ThanksShailen S.-------------Found my solution.The Variable mappings section allows you to define a variable that will hold the contents of the iterator. This will be a user defined variable.

    DB:2.35:Foreach sd

    see my first post. The issue has been resolved.
    Thanks
     
     

  • RELEVANCY SCORE 2.35

    DB:2.35:Receiving Errors When Using Foreach Loop And Excel Connection Manager... cp


    Purpose: Need to import excel source data into SQL Server 2005 tables. Excel source data comes in nulitple excel files with the same structure but different data. I would appreciate someone taking a look at the following information and notifying me of what I am doing incorrectly.  
     
    I Inserted a foreach loop container, a data flow task located inside the foreach loop contaiiner, an excel and SQL Server 2005 connections.
     
    After trying multiple times I went the following URL and followed step by step direction on how to connect excel workbooks dynamically: http://msdn2.microsoft.com/en-us/library/ms345182.aspx . I also used http://www.sqlstrings.com/ as a reference when creating the connection string.
     
     
    Creating a Foreach Loop Container:
     
    1. Opened foreach loop container 2.Set the Enumerator to 'Foreach File Enumerator and configured the enumerator by setting the directory location and file base name to E:\Clients\Dep Comm\BEA\BEA_Test_Source and *PersonnelExpense*.xls respectively. 3. Clicked Variable Mapping; created two variables called, ExcelFile, and ExtProperties and closed out of the foreach loop container.
     
    I. Created Excel Connection:

    Created excel connection called, “Dynamic Excel Connection Manager,” that initially pointed to one of the excel workbooks.
    Went to the connection properties by right clicking the connection manager.
    Expanded Expressions and clicked the  ellipsis button to bring up property expressions
    Chose Connection String in the Property.
    Clicked the Expression Ellipsis button.
    Put the following inside the Expression multi line text box:
    A.     Provider=Microsoft.Jet.OLEDB.4.0;Data Source= +  @[User::ExcelFile] + ;Extended Properties=\ + @[User::ExtProperties] + \

    Clicked the Evaluate Expression button to get the following:

    Provider=Microsoft.Jet.OLEDB.4.0;Data Source=;Extended Properties=
    Clicked Ok button
    Inserted a Data flow task inside the foreach loop container.
     
    II. Configured Tasks that is associated with Dynamic Excel Connection Manager or Package:

    Set the Foreach loop container Delay Validation to true.
    Set the Data Flow Task Container Delay Validation to true.
    Set the Dynamic Excel Connection Manager Delay Validation to true.
    Set the SQL Server Connection Manager Delay Validation to true.
    Set the Package Delay Validation to true.
    Package Locale ID set to English
     
     
    Ran the package after connecting the excel source data flow to the OLEDB destination and have inserted part of the error in this post. Please see below.
     
    Error: 0xC0202009 at Package, Connection manager Dynamic Excel Connection Manager: An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: Microsoft JET Database Engine  Hresult: 0x80004005  Description: Could not find installable ISAM..
     
    I modified the connection string after receiving the error by removing the extended properties. The following is the modified connection string: Provider=Microsoft.Jet.OLEDB.4.0;Data Source= +  @[User::ExcelFile]
     
    I repeated step I.6 above and received the following expression: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=
     
    I ran the package and received the following error in part:  OLE DB record is available.  Source: Microsoft JET Database Engine  Hresult: 0x80004005  Description: Unrecognized database format 'E:\Clients\Dep Comm\BEA\BEA_Test_Source\PersonnelExpense_OCCs_051007.xls'.
     
     
    I did not find anything helpful when I searched for the above errors and would very much appreciate anyone’s assistance on this issue as this issue needs to be taken care of ASAP.
     
    Does anyone have any ideas as to why I received this error and what can I do to resolve this issue?
     
    Your assistance in this matter is truly appreicated! 
    Thanks!!
    Lee
     

    DB:2.35:Receiving Errors When Using Foreach Loop And Excel Connection Manager... cp

    Actually, I figured out the problem. I was using the ConnectionString property to dynamically set the connection properties for each file inside the Foreach loop. I kept getting errors even though the evaluated connection string looked ok to me. I deleted that and only used ExcelFilePath. That worked... and also I set DelayValidation to True in all places. Thanks for the response though.

  • RELEVANCY SCORE 2.35

    DB:2.35:Unexpected Behavior Of Foreach Loop In Ssis 2012 km


    I have come across the unexpected behavior of Foreach Loop in SSIS 2012. While testing package for invalid folder (path asdf:\Vishal_Work does not exists in this case) for source files.

    I observed that the control does not enters into Foreach Loop, but also it does not fails the task. The task Foreach Loop runs successfully, though folder was invalid.
    The package did not throw any warning regardinginvalid folder, but for the unmatched file pattern.
    My concern is ‘why Foreach Loop in SSIS did not failed even if folder was invalid or not exists?’

    DB:2.35:Unexpected Behavior Of Foreach Loop In Ssis 2012 km

    Hi Arthur,
    Thanks for your reply, I have filed a bug. Bud ID: 820599

  • RELEVANCY SCORE 2.35

    DB:2.35:Loop Through Partially Filled Array Of Objects f3



    just insert a line like this at the start of the loop:

    for(int i = 0; i array.Length; i++) {
    if(array[i] == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    or, with a foreach loop:

    foreach(GameObject go in array) {
    if(go == null) {
    continue;
    }
    //whatever you want to do if there's actually something stored in this position
    }



    This will skip all the following code inside the loop and go on with the next array element.

    DB:2.35:Loop Through Partially Filled Array Of Objects f3


    If you're using C# you could use a HashSet. It both allows you to do a foreach, and also to Add and Remove elements with reasonable speed. An array is probably not the best choice for something which grows and shrinks dynamically.

  • RELEVANCY SCORE 2.35

    DB:2.35:Strange Problem With Foreach Loop ap


    I have a collection IEnamrablestring which I am trying to traverse via foreach loop, but sometime, foreach loop don't traverse all the items in the collection, instead, it comes out of the collection.

    IS IT POSSIBLE WITH FOREACH LOOP??????
    Thanks

    Please mark as answer, if you find this post helpful. Thanks Deepak Kalra

    DB:2.35:Strange Problem With Foreach Loop ap

    Hi Deepak,
    Since we haven't heard from you for a long time, I assumed the issue is resolved.I mark useful replies as answers. If you have any
    concerns, please feel free to reopen it or submit a new question. Thanks for your understanding.

    Regards,
    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • RELEVANCY SCORE 2.35

    DB:2.35:Manage Files With Uneven Number Of Columns f3


    Hi-
    I am having a scenario where i have to load various files from a folder into a table. But few files having uneven number of columns. In that case I have to move those files into a different location. All these files are getting loaded through an foreach
    loop container. I don't want the package to be failed. I only need to move those files to a different location and the package will pick the next file to process.
    I have followed the approach of setting the event handler of the package to on error and making the propagate property to true of the foreach loop and settng maximumerrorcountproperty to some value(let say)15. But
    still its getting failed in the DFT (In source) inside foreach loop.
    Please provide some insight, how to deal with such kind of scenario.
    Regards,
    Partha

  • RELEVANCY SCORE 2.35

    DB:2.35:Using -Match In An If Statement That Is Used In A Foreach Loop kz


    Hello Everyone,
    I have a script that is working, but I have a behavior that I cannot explain. This script asks will count the number of times a word is used inside a text file. The following script works. However, if I change the order of the match statement I get
    an error. I have not been able to explain the difference even with a couple hours of research. See the second code block for the changed version. All I did was change ($w -match $wordsearch) to ($wordsearch -match $w). When I do this I get the
    the error
    parsing prepare) - Too many )'s.
    At C:\Users\Administrator\Desktop\story-count.ps1:8 char:4
    if(($wordsearch) -match ($w)){
    If anyone can help me understand this I would greatly appreciate it!
    Thanks!

    $filepath = read-host Please type a file path
    $wordsearch = read-host Please enter a word to search for
    $content = get-content $filepath -Delim ' '
    $count = 0

    foreach($w in $content){
    if($w -match $wordsearch ){
    $count = $count 1
    }
    }

    Write-Host The word $wordsearch was counted $count times.
    Non-working code.
    $filepath = read-host Please type a file path
    $wordsearch = read-host Please enter a word to search for
    $content = get-content $filepath -Delim ' '
    $count = 0

    foreach($w in $content){
    if($wordsearch -match $w ){
    $count = $count 1
    }
    }

    Write-Host The word $wordsearch was counted $count times.

    DB:2.35:Using -Match In An If Statement That Is Used In A Foreach Loop kz

    Well it makes complete sense now! Things seem so simple once you have the answer. :D I did not even consider that -match is a regex. :\ Thank you both!

  • RELEVANCY SCORE 2.34

    DB:2.34:Foreach Of Columns Within Foreach Of Tabs km



    I have a site with a tabPanel and several tabs, which are all created via a forEach loop.

    Within these tabs is always one big dataTable, which has some dynamic columns, also created via forEach loops.

    The trouble is, when some of the data gets changed and some new columns get added to the dataTable. While athe actual columns get added, the forEach loop starts to behave weird. It iterates twice over some elements. E.g. when I use the varStatus and print out the index of it, the same index shows up twice. By clicking on the selected tab again, everything works fine again.

    The inner loop for the header looks like this (inside the dataTable), and similar for the actual data:

    f:facet name="header"
    rich:column colspan="#{viewerBean.nrScores}" id="header_scores"
    h:outputText value="Scores"/
    /rich:column

    c:forEach items="#{viewerBean.scoreFieldShorts}" var="score" varStatus="status"
    rich:column breakRowBefore="#{status.first}"
    h:outputText#{status.count} #{status.index} #{status.first} #{status.last}br/ /h:outputText
    /c:forEach
    /rich:columnGroup
    /f:facet

    DB:2.34:Foreach Of Columns Within Foreach Of Tabs km


    Ok, I found how to solve this.

    First I do a viewRoot.findComponent(...) and then table.getParent().getChildren().remove(table);

    So, after my update-calculations the whole new table gets rendered with correct header breaks.

  • RELEVANCY SCORE 2.34

    DB:2.34:Ado .Net Enumerator Fails When Importing Package To A New Solution d1


    so heres a pretty interesting dilemma...i have a ssis package that was created a while back in a particular solution on a server. the package read multiple sheets of an excel file and loaded data accordingly. oddly enough when i created a new solution and added this package to the new solution from the old solution (for the sake of being organized and being tidy)...when i run this from the new solution it fails. I've narrowed it down by disabling all the components except the ado .net jet connection and the foreach loop enumerator (which is the highest level in the package...so everythign else is inside it and has been disabled). after specifying the file name i even hit test connection and it passes. but the minute i run it the foreach loop fails saying Error: The GetEnumerator method of the ForEach Enumerator has failed with error 0x80131509 (null). This occurs when the ForEach Enumerator cannot enumerate.i've checked the connection over and over again...the machine is the same, the drive is the same, the only thing different is the solution. it works fine in the old solution but not in the new solution.thoughts?

    DB:2.34:Ado .Net Enumerator Fails When Importing Package To A New Solution d1

    Hi,You may try the following thread which maybe help.http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/7880ea1c-f685-4d2d-9413-0801a3729e4fThanks.Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • RELEVANCY SCORE 2.34

    DB:2.34:Foreach Loop In Ssis, Enumerator. p8


    Can anyone explain what enumerator means, and what role it has with running a Foreach loop in ssis.

    DB:2.34:Foreach Loop In Ssis, Enumerator. p8

    Foreach Loop enumerator means what you can loop. For example, it can be file enumerator that means you set a folder, and you can enumerate files in the folder. More detailed info is in http://technet.microsoft.com/en-us/library/ms141724.aspx .

  • RELEVANCY SCORE 2.34

    DB:2.34:Foreach Endless Loop f9


    I'm having a problem where I'm using a Execute SQL Task to retrieve a dataset and storing that in an object variable. Then on success of that execute sql task I use a foreach loop task to go through the dataset and do 2 tasks inside the foreach loop. When I execute this package I have ~12 records in the dataset however when I get to the foreach loop in the 2nd iteration it keeps repeating it. It acts like it is stuck on the second record (tuple) and never goes on. I'm using an ForEach ADO Enumerator in the foreach. I've even set a breakpoint on each iteration and no task fails in side the foreach loop. I'm completely perplexed why it will iterate to the 2nd record but get stuck there in an endless loop. I've tried this on 2 different computers (with different data values) and the same thing happens. Does anyone have any suggestions?

    DB:2.34:Foreach Endless Loop f9

    Sorry, I noticed that one of the causes, the checkpoint usage, had already been discovered before I posted. I apparently didn't view the last page of the thread before posting.

  • RELEVANCY SCORE 2.34

    DB:2.34:How To Send A Mail Through A Container Loop? 83


    hi everyone,
    I've created a Send Mail task which works properly and now I'd like to send that email n times.
    How do I such thing. I moved that task inside Foreach loop container and then I choosen Foreach From Variable Enumerator and then I've created a Int32 variable.
    And now,  I don't know how to tell that increments that variable
    TIA,

    DB:2.34:How To Send A Mail Through A Container Loop? 83

    Martin,
    Right on the target, thanks indeed.
    happy coding,

  • RELEVANCY SCORE 2.34

    DB:2.34:Foreach Statement With New In It 3x


     I'm not sure exactly what this does.Is the list being created each time through the loop?
    class Program
    {
    static void Main(string[] args)
    {
    string[] str = {apple,pear,banana};
    foreach (string s in new Liststring(str))
    {
    Console.WriteLine(s);
    }
    }
    }
    }

    DB:2.34:Foreach Statement With New In It 3x

     the new list will be stored in a temp var in the IL code. MSN:h2zy@hotmail.com

  • RELEVANCY SCORE 2.34

    DB:2.34:Can We Exit From Foreach Loop Container Using Script Task ? fx


    Can we handle the ForEach Loop container inside the script task? Ideally I'm looking to write exit Foreach Loop Container
    statement to maually exit from the foreach loop.

    DB:2.34:Can We Exit From Foreach Loop Container Using Script Task ? fx

    Thanks for your help. However, this thread doesn't serve my purpose.

  • RELEVANCY SCORE 2.34

    DB:2.34:Foreach File Loop Container - Cannot Open The Datafile fs


    Hi All, I have a fairly simple package that contains a Foreach Loop Container (Foreach File), and a Data Flow task inside of it that imports a flat .txt file into a database table.  Files are dropped into my directory constantly throughout the day which qualify for this process.  Every so often, my package fails with a Cannot open the datafile D:\Fileshare\myfile.txt error. I can rerun the package and everything functions perfectly.  My only thought is that the file is still being written as it's getting picked up by my Foreach File loop and the Data Flow task attempts to process it, causing the package to bomb.  I would have assumed, though, that files still being written to wouldn't qualify for the Foreach File loop.  Am I wrong in this assumption?  Has anyone seen this occur before?  Thoughts? Thanks! Jeff