Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
401 views
in Technique[技术] by (71.8m points)

c# - Crystal Reports keeps prompting for Parameter

I am having a terrible problem with crystal report 2010 for .net 4.0 (I am using the fixed 13.0.1 version but 13.0.4 is released). No matter which way I try, I am always getting a prompting dialogue box to input my one parameter value the first time.

CrystalReportViewer1.ReportSource = CustomerReport1;    
CustomerReport1.Database.Tables[0].SetDatasource ( this.dataset);        
CustomerReport1.SetParameterValue("PathLocation", Location.Text);

CustomerReport1.Parameter_PathLocation.CurrentValues.Add(Location.Text) // to be safe using CS 2010 for .net 4
CrystalReportViewer1.ReuseReportParametersOnRefresh = true; // to prevent from showing again and again.

I also tried this:

CustomerReport1.Database.Tables[0].SetDatasource ( this.dataset);        
CustomerReport1.SetParameterValue("PathLocation", Location.Text);

CrystalReportViewer1.ReportSource = CustomerReport1;

And this:

CustomerReport1.Database.Tables[0].SetDatasource ( this.dataset);        
CustomerReport1.Parameter_PathLocation.CurrentValues.Add(Location.Text)

CrystalReportViewer1.ReportSource = CustomerReport1; // the parameter in the report has Optional Parameter = false, Static , Multiple Value = false .

Can anyone please help? I am getting frustrated with this. It worked in previous versions, but now I am getting this prompt box.

Thank you.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Finally found the solution. It doesn't prompt if we set the DataSource after the ParameterValue.

So anyone of those will work if we put them in this order:

// First, call SetParameterValue. Then, call SetDatasource.     
CustomerReport1.SetParameterValue("PathLocation", Location.Text);
CustomerReport1.Database.Tables[0].SetDatasource(this.dataset);

CrystalReportViewer1.ReportSource = CustomerReport1;

Thank you all.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...