tag:blogger.com,1999:blog-2303058199815958946.post243805580517577380..comments2024-03-28T10:36:35.016+01:00Comments on Microsoft SQL Server Integration Services: Foreach folder enumeratorJoost van Rossumhttp://www.blogger.com/profile/01125981589974671317noreply@blogger.comBlogger23125tag:blogger.com,1999:blog-2303058199815958946.post-21006715684241024322016-08-01T13:45:31.205+02:002016-08-01T13:45:31.205+02:00Do not copy the whole script, but only the missing...Do not copy the whole script, but only the missing usings and then the contents of the Main method.Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-6952117994107617822016-07-26T14:34:10.862+02:002016-07-26T14:34:10.862+02:00encountered the same issue. did you get figured ou...encountered the same issue. did you get figured out what did you missed? I copied the whole script #4 using MVS2010/C#2010Tru Flamehearthttps://www.blogger.com/profile/08696192581430009151noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-54069977272095435452016-04-26T20:29:55.023+02:002016-04-26T20:29:55.023+02:00@Chaithanya Reddy Cheruku26: Please be more specif...@Chaithanya Reddy Cheruku26: Please be more specific. Or contact me via the webform in the menu.Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-69003018509234398372016-04-26T19:28:45.511+02:002016-04-26T19:28:45.511+02:00facing similar issue ssdt -2014. can you suggest m...facing similar issue ssdt -2014. can you suggest me a solution ?Anonymoushttps://www.blogger.com/profile/17010496295531891664noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-85937809573529250832015-10-31T20:57:18.277+01:002015-10-31T20:57:18.277+01:00I would add a IF construction in the subfolders me...I would add a IF construction in the subfolders method. Something like<br />if (!currentFolder.Equals("xxxxx"))<br />{<br />}<br />Or check one of the properties of directoryInfo:<br />if (!directoryInfo.FullName.Equals("xxxxx"))<br />{<br />}Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-53869978123945079822015-10-28T10:27:58.822+01:002015-10-28T10:27:58.822+01:00Hi Joost, Can you please help me how to exclude se...Hi Joost, Can you please help me how to exclude several folders with the loop? I have tried and still not working. Thanks.Kayhttps://www.blogger.com/profile/00431841620123671031noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-61230053558230671582015-09-20T12:53:48.720+02:002015-09-20T12:53:48.720+02:00Just a view and always the same? You could add a s...Just a view and always the same? You could add a simple if statement within the loop.<br />if (currentFolder.Equals("xxxxx"))<br />{<br />}<br />Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-62479787832718627952015-09-18T02:31:35.919+02:002015-09-18T02:31:35.919+02:00Thanks. This works very well for all folders. How ...Thanks. This works very well for all folders. How do I exclude some folders.Anonymoushttps://www.blogger.com/profile/07303520798651271590noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-22376450439898346492015-09-17T15:07:59.682+02:002015-09-17T15:07:59.682+02:00No! It just one of the possible solutions... you c...No! It just one of the possible solutions... you could also store a datatable in an object variable and then use a foreach ado enumerator... and there are even more possibilities.<br />Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-79863998879108356142015-09-10T17:27:58.836+02:002015-09-10T17:27:58.836+02:00Is XML really necessary? Can't you just use a...Is XML really necessary? Can't you just use an array or a list and make the variable type an object? For loop does have the option for looping a variable.Anonymoushttps://www.blogger.com/profile/03310035819160537674noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-26958849406986137282015-06-11T22:57:24.606+02:002015-06-11T22:57:24.606+02:00Worked very well for me in 2008 - thanks!Worked very well for me in 2008 - thanks!Anonymoushttps://www.blogger.com/profile/02410719461103371149noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-40358075704934007082014-05-16T20:03:05.670+02:002014-05-16T20:03:05.670+02:00Which version of SSIS are you using and which scri...Which version of SSIS are you using and which script did you use? 4 or 8? Did you copy the contents of the method or did you copy the whole script?Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-50803424105212332102014-05-16T18:06:56.320+02:002014-05-16T18:06:56.320+02:00Good article....However, when i tried this and exe...Good article....However, when i tried this and executed my package i got the following error:<br /><br />DTS Script has encountered an exception in user code:<br /><br />Project name: ST_01a52907a688442d8776aa9bf03b3a41<br /><br />Cannot load script for execution.<br /><br /><br />I have also tried to install the custom component but unfortunately after installation i cannot see the changes to my ForEach Loop Component.<br />G6Classichttps://www.blogger.com/profile/06395552566128281419noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-46191334696412590112013-10-25T15:32:24.175+02:002013-10-25T15:32:24.175+02:00For debugging you have to switch the project to 32...For debugging you have to switch the project to 32bit. You can also add a messagebox to check the value of the xml:<br /><br />// Fill SSIS variable with XMLdoc<br />Dts.Variables["xmldoc"].Value = xmldoc.InnerXml.ToString();<br />MessageBox.Show(xmldoc.InnerXml.ToString()); <br /><br />And if you don't have programming experience at all you could also try my custom enumerator:<br /><a href="http://microsoft-ssis.blogspot.com/2012/02/custom-ssis-component-foreach-folder.html" rel="nofollow">http://microsoft-ssis.blogspot.com/2012/02/custom-ssis-component-foreach-folder.html</a>Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-58534790266216214152013-10-25T14:47:48.575+02:002013-10-25T14:47:48.575+02:00Joost, I got an error on the actually For Each Loo...Joost, I got an error on the actually For Each Loop<br /><br />Error: 0xC0014023 at For Each Folder: The GetEnumerator method of the ForEach Enumerator has failed with error 0x80131943 "(null)". This occurs when the ForEach Enumerator cannot enumerate.<br /><br />Cracking piece of code but unfortunately I have no experience with C# so debugging is difficult.<br /><br />Any ideas?Anonymoushttps://www.blogger.com/profile/03542811946920695635noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-11137837286521119462012-08-22T01:36:05.847+02:002012-08-22T01:36:05.847+02:00Thank you JoostThank you JoostAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-27009283286823160162012-08-21T07:56:06.993+02:002012-08-21T07:56:06.993+02:00@Anonymous: Not sure I'm getting you...This fo...@Anonymous: Not sure I'm getting you...This foreach loop doesn't loop through files. Please explain your self or try this forum: <a href="http://social.msdn.microsoft.com/forums/en-us/sqlintegrationservices/threads/" rel="nofollow">http://social.msdn.microsoft.com/forums/en-us/sqlintegrationservices/threads/</a>Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-75975943381404572282012-08-21T01:56:13.372+02:002012-08-21T01:56:13.372+02:00Hi joost,
Thank you for your response,
I am using...Hi joost,<br /><br />Thank you for your response,<br />I am using 2008 version, i don't have permissions to install custom enumerator.<br />Actually i am looking some change in the script task (to include parent folder) , the output of the xml path contains parent folder and subfolders.so that below<br />foreachloop container loops all the files with out bypass the files of parent folder.this is my goal<br />Please consider it and let me known what change i need make in the scripttask<br /><br />Thanks<br />Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-88354889760917238992012-08-20T10:01:07.469+02:002012-08-20T10:01:07.469+02:00add something like this before calling GetSubFolde...add something like this before calling GetSubFolders from the main method:<br />xmlChildElem = xmldoc.CreateElement("", "Folder", "");<br />xmltext = xmldoc.CreateTextNode(Dts.Variables["User::startlocation"].Value.ToString()); <br />xmlChildElem.AppendChild(xmltext); Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-36419547428691985762012-08-20T09:41:13.061+02:002012-08-20T09:41:13.061+02:00Thank you for your response,
I am using 2008 versi...Thank you for your response,<br />I am using 2008 version, i don't have permissions to install custom enumerator.<br />Actually i am looking some change in the script task (to include parent folder) which you provide for looping over subfolders, the output of the xml path contains only subfolders<br /><br />* MOVED FROM Custom SSIS Component: Foreach Folder Enumerator *Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-67640090953073703452012-07-24T16:40:15.856+02:002012-07-24T16:40:15.856+02:00I think it's a typo in the variable name...I think it's a typo in the variable name...Joost van Rossumhttps://www.blogger.com/profile/01125981589974671317noreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-46971910921266143782012-07-24T16:16:06.489+02:002012-07-24T16:16:06.489+02:00Hey thanks for your article actually I am very new...Hey thanks for your article actually I am very new to SSIS ad tryig to learn this .<br />I am getting this error when I follow the article<br /><br />Error: Failed to lock variable "User::startloaction" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".<br /><br /><br />All the three variables are in the Foreach scopeAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2303058199815958946.post-70615456848784103332012-05-06T21:13:43.606+02:002012-05-06T21:13:43.606+02:00Thanks bro. Helped a ton.Thanks bro. Helped a ton.Anonymousnoreply@blogger.com