I have following Dataflow:
Control:
I just wanted to copy all the data from flatfiles in sourcefolder to sql database and after copying move those files to folder named Done.
But when i run this, i get error:
[File System Task] Error: An error occurred with the following error message: "The process cannot access the file because it is being used by another process.".
Data gets copied to sqlserver , but file does not moves.
My process tab is as follows:
If you are using Excel connection from SSIS connection Manager. There is a property RetainSameConnection. It is true by default. Make it False and you will be all set.
Add a script task executing below mentioned lines, before doing file operation:
Public Sub Main()
Dim procList() As Process = Process.GetProcesses()
Dim k As Integer
For k = 0 To procList.GetUpperBound(0) Step k + 1
If procList(k).ProcessName = "EXCEL" Then
procList(k).Close()
procList(k).Dispose()
End If
Next
GC.Collect()
GC.WaitForPendingFinalizers()
Dts.TaskResult = ScriptResults.Success
End Sub