Params Problem

mammam
edited 4:35AM in FastReport 3.0
Hi

it is easy to pass params to query but there is problem with (in) expression such as

select * from tbl a
where a.fld in :param1

if you called it by this script
q.params[0].value := (1,4,5,9,11);

you will get error
pleas help me...........................thanks

Comments

  • edited 4:35AM
    use this code:

    var param1 string;

    param1 := '(1,4,5,9,11)';
    sql_msg= 'select * from tbl a where a.fld in ' + param1

    then execute it!
  • mammam
    edited 4:35AM
    thenicespider thank's a lot

    I tried this code

    var param1 string;

    param1 := '(1,4,5,9,11)';
    sql_msg= 'select * from tbl a where a.fld in ' + param1

    and this
    sql_msg= format('select * from tbl a where a.fld in %s ',<var1>)

    its runnig good from report desiner but its not when you try to load report from delphi whith variables such as

    frxrep1.variables := '(1,4,6)';

    important note a.fld is integer field
  • gordkgordk St.Catherines On. Canada.
    edited 4:35AM
    try adding extra quotes
    frxrep1.variables := ''''+'(1,4,6)'+'''';
    ;)
  • mammam
    edited 4:35AM
    thank's for all

    when i try to add extra quotes

    frxrep1.variables := ''''+'(1,4,6)'+'''';

    i eceived this error mssage
    could not convert variant (string) into type (double)
  • gordkgordk St.Catherines On. Canada.
    edited 4:35AM
    since it works when you hard code the value in the variable
    "sql_msg= format('select * from tbl a where a.fld in %s ',<var1>)
    its runnig good from report desiner"
    the problem is usually in the code where we pass the value from delphi to the variable, delphi strips the '
    here is a tip on how to find, it look at the hardcoded value (that works) in the variable and note how it appears, now go to delphi and where you load the report and set the variables value instead of calling showreport call design report when the designer comes up look at the variable and see what has been placed in the variables expression if it doesnt match what you would have hardcoded go back out to delphi and adjust delphi code, repeat untill you get it correct.
    ;)
  • mammam
    edited 4:35AM
    gordk.
    thank for value advice
    yes i found the problem and fix it

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.