crystal reports selection formula and sql query in c#

Posted on 2010-01-06
Last Modified: 2012-05-08
i'm using crystal reports that comes bundled with visual studio 2005

im passing a selection formula to the crystal reports using the codebehind c# of
in this selection formula im passing a date range and a range of figures
how do i get to display this in the crystal report itself [on the rpt page] ?

also, after i finish designing the report using the wizard [form groups, add formulas, etc] ... during checking the sql query, i see the order by clause. i think this causes a lot of slow down while generating the report. is there any way to remove the order by clause?
Question by:RakeshBhandari
    LVL 34

    Accepted Solution

    I haven't used that version of CR, so I don't know what the designer is like, but the basic way to show a parameter on a report is just to drag and drop it on the report.  However, if the parameter accepts ranges or multiple values, that won't work.  For a parameter that accepts a single range, you can create formulas like the following and put those on the report:

    // start date
    Minimum ({?date parameter})

    // end date
    Maximum ({?date parameter})

     Or, you can get a little more sophisticated and do some formatting in a formula, like:

    "From " + CStr (Minimum ({?date parameter}), "dd/MM/yyyy") +
     " to " + CStr (Maximum ({?date parameter}), "dd/MM/yyyy")

     Change the date formatting as you see fit.  Look for CStr in the CR Help to see a list of formatting codes.

     If your parameters allow multiple values, that gets more complicated.  You can see some example formulas to handle that kind of thing at:

     As for the "order by" thing, if that's in your SQL query, I'm not sure that you want to get rid of it.  It's usually a good thing.  But if you do, you can see if you have a File > "Report Options" item in the designer.  If so, see if there is a "Use Indexes Or Server for Speed" option there.  If it's checked, you can try unchecking it and see what happens.  In a quick test I just did here using CR 10, that got rid of the ORDER BY clause that was in my SQL query.  But, like I said, that's usually something that you would _want_ sent to the server.

    LVL 2

    Author Closing Comment

    thank you!
    LVL 34

    Expert Comment

    You're welcome.  Glad I could help.


    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now