SQL Query from VS to Fast Report

Hi,

I have to send custom SQL query from my application to Fast Report, How Can I do that??

I set parameter in Fast Report, and I sent the sql query to this parameter from my application

report1.SetParameterValue("sqlQuery", sqlQ);

But, To what object/data/ shall I set the parameter inside Fast Report?

Thanks,

Comments

  • edited 9:56AM
    You need to do the following:
    - run the designer
    - select the "Report" object (in the "Properties" window)
    - switch to events and create the "StartReport" event handler
    - write the following code in it:
          TableDataSource data = Report.GetDataSource("Products") as TableDataSource;
          data.SelectCommand = (string)Report.GetParameterValue("my param");
    
  • edited 9:56AM
    Hi,

    I did as you said but I got no error, just the application halt:


    report1.Load("calllogs.frx"); //load the report
    string sqlQ = createSQLStatement(); // this will create SQL query
    FastReport.Data.TableDataSource data = report1.GetDataSource("myTableName") as FastReport.Data.TableDataSource;
    data.SelectCommand = (string)report1.GetParameterValue(sqlQ);
    report1.Show();

    Is there is something wrong in this code??





  • edited 9:56AM
    Strange, it works well for me. One important note: the query defined in the report must have the same data columns. I.e. you may change the "where", "order by" conditions, but don't change the "select" - in this case the query will return the different set of data columns, and report will stop work.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.