2011-06-15 2 views
1

SSISパッケージを使用して、出力としてExcelSheetを生成しています。私はC#ソースコードを介してSSISパッケージを呼び出しています。実際には、ファイルをpkgTR.Variables ["dPath"]。Value = @ "c:\" + sFileName;として保存しています。SSISパッケージの出力を動的に保存する

エンドユーザーに名前を付けて保存 - 誰がファイルをC:\またはD:\に保存するか、いつどこでファイルを保存するかを決定します。あなたがパッケージを起動し、あなたがそれを実行すると、あなたのSSISパッケージにディレクトリパスを渡す前に、

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); 
} 

答えて

1

あなたがC#でダイアログをポップアップ表示することができないのC#からパッケージを起動している場合は?

+0

私はいいですが、サンプルコードは何ですか? – goofyui

関連する問題