I have been developing a package which moves excel files from staging folder to archive folder, once those files are used by an excel connection manager.
I have a foreach loop container which goes through all the files of the staging folder. In the foreach loop container, I have a script task which has following code only:
Dts.Connections["Excel Connection Manager 1"].ReleaseConnection(null);
//Excel Connection Manager 1 is the connection which uses the excel files. My logic behind this is to release the locks on the files if any. I am not sure if NULL is working though
Next is an Execute sql task which only has 'WAITFOR DELAY '00:00:01' in it. I googled a lot and this was suggested at many places..
Now I have the actual move file task which moves the files from staging folder to the archive folder.
So, the process works well for all the files except the last one. The last file still remains locked by the excel connection manager and that is why the move file task fails.
I also scripted the move file using the example given here : LINK
That doesn't fail the package, but doesn't move the last file as well.
I also tried 'Dts.Connections["Excel Connection Manager 1"].Dispose();' instead of releaseconnection, but thats not helping either
Can anyone please help me out here..
Thanks in advance!!