views:

600

answers:

1

I am adding a crystal report to a ASP.net MVC project. I need to be able to change the parameters (crystal report filter) on the report to be dynamically changed in the code. Is there an easy way to do this?

A: 

Do you want the parameters, formulas or the record selection formula to be changed?

Most of the time (with crystal reports), you only need to change the selection formula. Look in reports --> Selection Formulas --> Record Formula.

I believe this text is what you need to change.

so, if the formula is {file.field}=2009, you may want to do (like) the following in .NET

dim sFormula as string = "{file.field}="+cStr(iParam)
dim CustReport as new CrystalReport
custReport.reportSource = "test.rpt"
custReport.RecordSelectionFormula =sFormula
custReport.print

I don't use .NET, so have had to convert my own code to this, so don't be suprised if it doesn't work. My advice stands though: You don't need to use parameters, and you should build your report filter using "RecordSelectionFormula"

seanyboy