首先,引用10.0.0.0版本dll,如下:
using microsoft.sqlserver.dts.runtime.wrapper;
代码如下:
public int executessasdts()
{
string filepath = urlconvertorlocal(package.dtsx);
if (!system.io.file.exists(filepath))
{
return 2;
}
// call ssis package from sql server.
application application = new applicationclass();
idtspackage100 package = application.loadpackage(filepath,false,null);
dtsexecresult result = package.execute();
if (result.equals(dtsexecresult.dtser_success))
{
return 1;
}
else
{
return 0;
}
}
//相对路径转换成服务器本地物理路径
private string urlconvertorlocal(string imagesurl1)
{
string tmprootdir = server.mappath(system.web.httpcontext.current.request.applicationpath.tostring());//获取程序根目录
string imagesurl2 = tmprootdir + //dashboard// + imagesurl1.replace(@/, @/); //转换成绝对路径
return imagesurl2;
}
这个问题困扰了我好久,现发出来与大家共享,希望能给一些想我一样的菜鸟一些帮助
