【问题标题】:Dynamically Saving the output from SSIS Package动态保存 SSIS 包的输出
【发布时间】:2011-06-15 17:05:20
【问题描述】:

使用 SSIS 包,我生成 ExcelSheet 作为输出。我正在通过 C# 源代码调用 SSIS 包。目前我实际上将文件保存为:pkgTR.Variables["dPath"].Value = @"c:\" + sFileName;

我们希望将功能另存为给最终用户 - 最终用户决定将文件保存在 C:\ 或 D:\ 或他想要保存文件的任何位置。

try
{
    string pkgTRPath = @"C:\Reports\SSISPackages\GenerateTransactionReport.dtsx";
    Package pkgTR;
    Microsoft.SqlServer.Dts.Runtime.Application app;
    DTSExecResult pkgResults;

    app = new Microsoft.SqlServer.Dts.Runtime.Application();
    pkgTR = app.LoadPackage(pkgTRPath, null);

    pkgTR.Variables["sConn"].Value = System.Configuration.ConfigurationManager.AppSettings["SSISConn"];
    pkgTR.Variables["sDate"].Value = txtFromDate.Text;
    pkgTR.Variables["eDate"].Value = txtToDate.Text;
    pkgTR.Variables["sSortCode"].Value = drpSortCode.SelectedValue.TrimEnd();
    string sFileName = "TransactionReport_" + drpSortCode.SelectedValue.TrimEnd() + ".xls";
    pkgTR.Variables["dPath"].Value = @"c:\" + sFileName;

    pkgResults = pkgTR.Execute();
    var reportID = drpSortCode.SelectedValue.TrimEnd();

    if (pkgTR.ExecutionResult.ToString() == "Success")
    {
        Response.Write(String.Format(@"<script language=javascript>alert('Excel Report for {0} is Generated');</script>", reportID));
    }
    else if (pkgTR.ExecutionResult.ToString() == "Failure")
    {
        Response.Write("<script language=javascript>alert('Failure:Unable to generate report!!');</script>");
    }
}

catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

【问题讨论】:

    标签: c# sql-server-2005 sql-server-2008 ssis


    【解决方案1】:

    如果你是从 C# 调用包,你不能在启动包之前在 C# 中弹出一个对话框,然后在执行它时将目录路径传递到你的 SSIS 包中吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-13
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多