in current project have take excel file of known directory unknown name, put database table , move , rename excel file used.
as first project i've used few tutorials , stackoverflow pages long way, hence why control flow inside each loop (even if might not needed), here control flow:
http://i.stack.imgur.com/nepgg.png
here script task find excel file , assign variables:
public void main() { string directorylocation = @"i:\all\l3va import\"; //change new directory int directorylength = directorylocation.length; string[] filepath = directory.getfiles(directorylocation, "*.xls*"); int filepathlength = filepath[0].length; dts.variables["myconnectionstring"].value = filepath[0]; dts.variables["myfilename"].value = filepath[0].substring(directorylength, filepathlength - directorylength);
i use data flow task pump spreadsheet data ole db, doesn't work on own, works if script task executed first, making me believe correctly assigning variables.
my issue comes when try move , rename file using file system task, seems not find value of these variables , encounters error:
error: 0xc002f304 @ file system task, file system task: error occurred >the following error message: "could not find part of path.".
task failed: file system task
here variable list used , file system task: http://i.stack.imgur.com/p6fwd.png
seems me how decide excel file appropriate if more 1 file exists. need loop through multiple of them? anyway, if use foreach loop container
, set search directory script wont need script task. follows:
- setup variable hold file path
- add
foreach loop container
, configure search directory , map variable setup - add
data flow
- after setup
data flow
on staticexcel connection
setupexpression
onconnection manager
usefile path variable
connection string
- add file system task , set source path variable
note because need build destination path dynamically want few more variables accomplish task in easier manner.
- filepath - hold file name , extension
foreeach loop
- fullfilepath - dynamic variable uses expression combine filepath directory being searched, used in excel connection manger , source on file system task.
- destinationfullfilepath - expression combines filepath destination directory, used destination on file system task.
Comments
Post a Comment