c# - Assign value to variable using LINQ in SSIS Script task -


i trying loop through folder. suffix of each file can found in column in sql table. suffix where linq statement , variable in script task (shown on comments). predicate true, want return value column on same row in sql table, , assign other column's value variable in script task. doing messagebox.show test.

i have set oledb connection manager in ssis package, i'm not sure how can run linq query inside task, think i'm missing in how have set connection. pointers gratefully received. here's how far i've got:

public void main() {     string sourcepath = dts.variables["user::sourcepath"].value.tostring();     string archivepath = dts.variables["user::archivepath"].value.tostring();     string destinationpath = dts.variables["user::archivepath"].value.tostring();      sqlconnection conn = new sqlconnection();     conn = (sqlconnection)(dts.connections["server.database"].acquireconnection(dts.transaction) sqlconnection);      directoryinfo directoryinfo = new directoryinfo(sourcepath);     fileinfo[] files = directoryinfo.getfiles();      foreach (fileinfo fileinfo in files)     {         string filename = fileinfo.tostring();         filename = filename.split('_')[0]; // file suffix         string destinationprefix = "";         // linq here using filename variable:           //destinationprefix = t in table t.column == filename select destinationprefixcolumn         messagebox.show(destinationprefix);                 } } 

imran,

you need give more information on table object. there no code grab data data base table variable.

var query = "select * sometable somecondition order somefields"; var table = conn.executequery(query); 

that table can scan inside fileinfo loop. since didn't tell fields @ extension or doing source , destination folders. can give no further code. also, have @ things in fileinfo object may useful...

fileinfo.filename //name of file fileinfo.fullname  // full path , name of file fileinfo.extension  // extension fileinfo.moveto()  // move file new location fileinfo.copyto()  // copy file new location 

post , clarify question receive more help.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -