SSIS - The process cannot access the file because

2020-04-04 04:54发布

I have following Dataflow:

enter image description here

Control:

enter image description here

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:

enter image description here

8条回答
一纸荒年 Trace。
2楼-- · 2020-04-04 05:28

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.

查看更多
Emotional °昔
3楼-- · 2020-04-04 05:28

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

查看更多
登录 后发表回答