我正在使用ASP.NET MVC 4和实体框架。我创建了一个SSIS包,它从Excel文件中提取数据并将其存储到数据库的表中。带有文件的SSIS包通过ActionResult
我想要做的就是使用我的SSIS包与上传的Excel文件(到ActionResult
)来存储数据。
这里我有一个代码示例,它返回我“成功”。所以包正确执行:
Console.WriteLine("Loading SSIS Service...");
//Application object allows load your SSIS package
Application app = new Application();
//In order to retrieve the status (success or failure) after running SSIS Package
DTSExecResult result;
//Specify the location of SSIS package - dtsx file
string SSISPackagePath = @"C:\Package.dtsx";
//Load your package
Package pckg = (Package)app.LoadPackage(SSISPackagePath, null);
//Execute the package and retrieve result
result = pckg.Execute();
//Print the status success or failure of your package
Console.WriteLine("{0}", result.ToString());
Console.ReadLine();
有关如何将其与上传的文件耦合的任何想法?
编辑:好的包装工作正常,我只需要修改源文件。任何想法?
EDIT(2):在此之后,问题已经解决了Excel文件的情况下,我想知道是否有可能做这做同样的事情了平面文件:
pckg.Connections["NameOfTheConnectionManager"].ConnectionString = @"C:\Test-CSV.csv";
result = pckg.Execute();
最好就第二次编辑提出一个新问题。 – 2014-08-29 18:29:20