sql server - SSIS Foreach Flatfile Connection issue -


i have 1 directory of .csv files want load db each table titled after .csv title.

i have foreach loop handle this. variable current dir, current file, , tblname defined , modified scripting actions.

the last command of foreach loop updates current file variable, not seem refresh flat file connection debugging fails error stating column found in previous csv expected not found in datasource (which next csv in dir)

control flow: enter image description here

data flow 'insert new data target' enter image description here

and here's code updating var's @ end of for/each loop.

    int pos = (int)dts.variables["user::pos"].value;     string dirpath = (string)dts.variables["user::sourcefolder"].value;     pos++;     dts.variables["user::pos"].value = pos;      //object ffconnection = dts.connections["csv file"].acquireconnection(dts.transaction);     //string filepath = (string)ffconnection;     //messagebox.show(ffconnection.tostring());     //dts.connections["csv file"].releaseconnection(ffconnection);      directoryinfo di = new directoryinfo(dirpath);     fileinfo[] diar1 = di.getfiles("*.csv");     fileinfo next;     string nextpath;     string tblname;      //messagebox.show(next.fullname);      if (diar1.length > 1){         next = diar1[pos];         nextpath = next.fullname;         tblname = path.getfilenamewithoutextension(nextpath);         dts.variables["user::currentfile"].value = nextpath;         dts.variables["user::tblname"].value = tblname;         messagebox.show("script's tblname: " + tblname);         messagebox.show("user::tblname: " + (string)dts.variables["user::tblname"].value);         messagebox.show("user::currentfile: " + (string)dts.variables["user::currentfile"].value);     }       dts.taskresult = (int)scriptresults.success; 


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -