The apostrophe (') processing in the report parameter exceeded expectations
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].
Report parameters [PNames] Assign values in C # code:
Obviously, I expect the SQL query statement as follows:
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:
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:
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
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
Great, it's OK, Thank you very much for your time.