Reputation: 41
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();
Upvotes: 1
Views: 130
Reputation: 1332
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.
Upvotes: 1
Reputation: 11
I think you should use the SetReportSource method, then SetParameterValue before loading the report.
Upvotes: 1