Vinicius Ottoni
Vinicius Ottoni

Reputation: 4677

How to change the query of a crystal report file (.rpt)?

I need to change the query of my crystal report file (.rpt) depending of a filter (where clause). How can i do this (change the where clause of my query)? (In the code behind)

Obs: i'm using crystal report 13, .net framework 4.0 and c#.

Upvotes: 0

Views: 3232

Answers (1)

Ryan
Ryan

Reputation: 7287

Generally speaking, you can add conditions to the WHERE-clause by adding them to the report's record selection formula. For example, if you want records in the Order table that match, say, location 1 and last year then you can do something like:

string selectFormula = "{Order.LocationID} = 1 AND {Order.Year} = 2011";

Then add to your report definition via

crystalReportViewer.SelectionFormula = selectFormula;

Upvotes: 1

Related Questions