Wednesday, December 2, 2015

Error Cannot open the datafile \\server\share\dir\filename.csv when reading from a CSV file in SSIS

I am getting this error when a Flat File connection tries to read a CSV file. The path to the file, including the file name is correct.

The import works fine when the path to the file is hard-coded. It does NOT however work (with the above error), when I set the Flat File Connection Manager Connection String Property in a VB Script Task.

I am using this to set the Connection String and it does get set correctly. A Variable (strFileLocationFileName contains the File Path and File Name).

ConnectionManager.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strFileLocationFileName & ";Extended Properties=""text;HDR=YES;FMT=Delimited"";"

The issue was resolved when I removed this Script Task and instead assigned the File Name and File Location to the Flat File Connection Manager Connection String as an Expression using the strFileLocationFileName Variable.


No comments:

Post a Comment