2011-05-13 37 views
2

hi 我是新來的水晶報表和ASP.NET 我有一個水晶報表,我想要的只是通過我的asp.net頁面將一個參數傳遞給該報表ASP.NET c#將參數值傳遞給Crystal Report

這裏是即時通訊使用

protected void setParameterField() 
{ 
    string strReportPath = "\\\\fileserver\\crude Accounting\\reports\\MonthReportNew.rpt"; 
    string weekReportPath = "\\\\fileserver\\crude Accounting\\reports\\" + "WeekWise.rpt"; 

    try 
    { 
     if (!System.IO.File.Exists(strReportPath)) 
     { throw (new Exception()); } 
    } 
    catch (Exception ex) 
    { 
     Response.Write("You Might Not Have Permission To View This Report. Please Contact System Administrator"); 
     Response.Write(Convert.ToString(ex.Message)); 
     return; 
    } 

    //Main Report 
    ReportDocument cryRpt = new ReportDocument(); 
    cryRpt.Load(strReportPath); 
    //Sub Report - Week 
    ReportDocument weekReport = new ReportDocument(); 
    weekReport.Load(weekReportPath); 

    ParameterFields paramFields = new ParameterFields(); 
    ParameterField paramField = new ParameterField(); 
    ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue(); 
    paramField.Name = "@Document_No"; 
    paramDiscreteValue.Value = "BAD-0511-PRO-2"; 
    paramField.CurrentValues.Add(paramDiscreteValue); 
    paramFields.Add(paramField); 

    CrystalReportViewer1.ParameterFieldInfo = paramFields; 
    cryRpt.SetParameterValue("@Document_No", "BAD-0511-PRO-2"); 
    cryRpt.SetDatabaseLogon("myuserid", "mypassword");   
    CrystalReportViewer1.ReportSource = cryRpt; 

} 

我汽車無收到錯誤缺少參數的代碼值 我不知道什麼是錯,此代碼.. 請幫我

回答

3

您必須將參數傳遞給您的Crystal Report Source。像...

CrystalReportSource1.ReportDocument.SetParameterValue(0, "ParameterValue"); 
+0

這樣做的伎倆...非常感謝你:) –