简体   繁体   中英

How do i stop crystal report from requesting parameters at runtime even after i supply them from c# code?

I already provided the parameters from the code behind as shown below, but each time i run, crystal report still requests parameters. Is there a block of code i am missing?

    string connectionString = WebConfigurationManager.ConnectionStrings["SCHOOLConnectionString"].ConnectionString;
    SqlDataAdapter DA;
    SqlDataAdapter dataAdap;
    DataSet DS = new DataSet();
    DataSet dataSet = new DataSet();
    ReportDocument RD = new ReportDocument();
    SqlConnection myConnection = new SqlConnection(connectionString);
    myConnection.Open();
    DA = new SqlDataAdapter("SELECT * FROM Exams WHERE AdmissionNo='RLA 0034'", myConnection);
    DA.Fill(DS);
    dataAdap = new SqlDataAdapter("SELECT * FROM RESULT WHERE AdmissionNo='RLAS  0005'", myConnection);
    dataAdap.Fill(dataSet);
    RD.Load(Server.MapPath("~/CrystalReport1.rpt"));
    RD.SetParameterValue("PicPath",@"C:\Users\Me\Pictures\abu.jpg");
    RD.DataSourceConnections.Clear();
    RD.SetDataSource(DS.Tables[0]);
    RD.Subreports[0].DataSourceConnections.Clear();
    RD.Subreports[0].SetDataSource(dataSet.Tables[0]);
    CrystalReportViewer1.ReportSource = RD;
    CrystalReportViewer1.DataBind();

我认为您应该在加载报告之前使用SetReportSource方法,然后使用SetParameterValue。

From my experience with the Crystal SDK, it will always pop that up at runtime unless you set all of the parameters the report has. Double check the report and make sure you're not missing any.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM