The apostrophe (') processing in the report parameter exceeded expectations

edited 10:40AM in FastReport .NET
Hi all,

The data source of the following SQL query is defined in the FastReport.net report, where the expression of the @NAMES variable refers to the report parameters [PNames].
SELECT * from Table1 where name in (@NAMES)

Report parameters [PNames] Assign values in C # code:
Rpt. SetParameterValue ("PNames", "'A','B','C'");

Obviously, I expect the SQL query statement as follows:
SELECT * from Table1 where name in ('A','B','C')

But debugging found that FastReport put me in the string all the single quotes plus a layer, the final execution of the SQL statement into the following appearance:
SELECT * from Table1 where name in (''A'',''B'',''C'')

The result is obviously totally wrong!

I tried to pass only one value without single quotation marks, and ultimately because Fr added a single quote, the SQL statement was correctly spliced:
Rpt. SetParameterValue ("PNames", "a");

Try a variety of combinations, as long as the string contains single quotes, FR will eventually turn a single quotation mark into two, for a long time, who knows exactly how to write it?

Thanks

Comments

  • edited 10:40AM
    Please help me, thank you very much!
  • edited 10:40AM
    try to construct parameterized query from report script
        private void _StartReport(object sender, EventArgs e)
        {
          string parameter = Report.GetParameterValue("MyParameter").ToString();
          TableDataSource tds = Report.GetDataSource("YourDataSourceName") as TableDataSource;
          tds.SelectCommand = "SELECT * from Table1 where name in (" + parameter + ");";
        }
    
  • edited 10:40AM
    ipong wrote: »
    try to construct parameterized query from report script
        private void _StartReport(object sender, EventArgs e)
        {
          string parameter = Report.GetParameterValue("MyParameter").ToString();
          TableDataSource tds = Report.GetDataSource("YourDataSourceName") as TableDataSource;
          tds.SelectCommand = "SELECT * from Table1 where name in (" + parameter + ");";
        }
    

    Great, it's OK, Thank you very much for your time. >>>

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.