问题
I have an SSIS package that imports Excel files. Inside the package, I have a Script task that checks whether the Excel file exists or not before executing the Excel import process.
I am unable to execute the package when the Excel file doesn't exist because of the AcquireConnection
error.
How can I prevent the package from executing when there is no Excel file available for import?
回答1:
Perform the following steps to avoid the package from failing.
- Set the
ValidateExternalMetadata
property on the Excel Source toFalse
. - Set the
DelayValidation
property on the Excel Connection toTrue
.
The package validation phase happens first even before your Script task can execute. If the Excel file, doesn't exist then the package validation phase will fail. Setting the above property values will delay the validation and you can check if the first exist or not in your script task. If the file doesn't exist, you can abort the package execution.
来源:https://stackoverflow.com/questions/10293401/how-to-prevent-excel-import-in-ssis-package-when-there-is-no-file-to-process