none
Validate the expression syntax RRS feed

  • Question

  • Hi,
        How do I programatically (C#.Net or VB.Net) check the syntax of an expression in an RDLC file. e.g iif(expression, trueblock, falseblock) I want to validate whether the syntax is correctly written. I have the expression, but now I want to validate it whether it has correct syntax or not.

    Thanks.


    Thanks and Regards, Vikram
    Tuesday, June 2, 2009 8:38 AM

Answers

  • Yes I got it. Thanks to "http://blogs.msdn.com/brianhartman" Brian Hartman. What I did was, - I created a dummy RDLC. - In the Body section add a TextBox. - Then set the expression as the value of the textbox. - Use LocalReport object and try to load the RDLC. - If it loads succesfully then the expression is correct or else there is some error in the expression. Brian Hartman's comment ....Most people don't realize it, but the LocalReport object can be instantiated independently of the ReportViewer. That is, you can just call "new LocalReport()" and use the report object without the UI. This is useful for printing or exporting without the UI, ..... After you supply the report definition to the LocalReport object, you just need to call a method that forces the report to be compiled, such as GetParameters().

    Cheers.
    Thanks and Regards, Vikram
    • Marked as answer by VNSuvarna Friday, June 19, 2009 9:17 AM
    Friday, June 19, 2009 9:16 AM

All replies

  • It does that for you as you type. So for an IIf() statement in the expressions dialog, you go to Common Functions->Program Flow and dbl click IIf(), it tool tip's the values required and anything that can't get resolved is underscored in a jagged red line.

    So if you have a boolean comparison for the expression, it'll let you know if that's valid or not, which is what I think you're after.
    Wednesday, June 3, 2009 3:38 PM
  • Thanks for your response. You are right that the expression dialog in MSreport designer will do the validation. But I am generating my rdlc file dynamically, based on what user has set in my custom report designer. I need to put the syntax checker function in my designer. How do I do that.
    Any idea?

    Regards,


    Thanks and Regards, Vikram
    Friday, June 12, 2009 8:32 AM
  • Yes I got it. Thanks to "http://blogs.msdn.com/brianhartman" Brian Hartman. What I did was, - I created a dummy RDLC. - In the Body section add a TextBox. - Then set the expression as the value of the textbox. - Use LocalReport object and try to load the RDLC. - If it loads succesfully then the expression is correct or else there is some error in the expression. Brian Hartman's comment ....Most people don't realize it, but the LocalReport object can be instantiated independently of the ReportViewer. That is, you can just call "new LocalReport()" and use the report object without the UI. This is useful for printing or exporting without the UI, ..... After you supply the report definition to the LocalReport object, you just need to call a method that forces the report to be compiled, such as GetParameters().

    Cheers.
    Thanks and Regards, Vikram
    • Marked as answer by VNSuvarna Friday, June 19, 2009 9:17 AM
    Friday, June 19, 2009 9:16 AM