2009-02-09 75 views
0

我試圖導出爲PDF水晶報表,然後通過電子郵件發送,但每次我到導出命令時,我得到一個ParameterFieldCurrentValue例外。與Crystal參數問題報告出口

我跟蹤的參數集合的值保持ReportDocument和值被設置在那裏。而且,所有四個參數都是字符串。第一個設置允許多個值以及離散值或範圍值。我調用的對話框爲該參數的可選選項設置值。沒有其他參數字段。在報告中有公式字段。

我的代碼是:

SelectionDialog sd = new SelectionDialog(null, null, 
@"\\er1\common\bfi_apps\ReportMasterTwo\eds\custno.csv", true, false); 
DialogResult dr = sd.ShowDialog(); 
string filename = @"c:\documents and settings\aap\desktop\salesanalysis.pdf"; 

if (dr == DialogResult.OK && sd.selectedVals != null) 
{ 
    for (int i = 0; i < sd.selectedVals.Count; i++) 
    { 
     ar100SalesABC_edcustom1.Parameter_Customer_Number.CurrentValues.AddValue 
    (sd.selectedVals[i]); 
    } 

    ar100SalesABC_edcustom1.Parameter_Fiscal_period.CurrentValues.AddValue("1"); 
    ar100SalesABC_edcustom1.Parameter_Fiscal_year.CurrentValues.AddValue("2007"); 
    ar100SalesABC_edcustom1.Parameter_Product_Type.CurrentValues.AddValue("F"); 


    ar100SalesABC_edcustom1.ExportToDisk 
    (ExportFormatType.PortableDocFormat, filename); // ERROR HAPPENS HERE 

    // .. emailing code and other stuff 
} 

我在做什麼錯?有沒有其他方法可以做得更好?我試過導出選項,我試過SetParameter,我一直在收到這個錯誤。

回答

0

我結束了使用SetParameter而不是當前值方法,並使用值集合的多值參數。

而不是使用類型的報告,我使用了一個無類型的報告文檔。

我還從Crystal Reports中複製了SQL,並用它來創建數據集。我認爲數據集是我之前缺少的部分。

它現在可以工作,儘管它看起來不像上面的代碼。