problem when running select on more than one table in Delphi and Firebird

Asked

Viewed 91 times

0

select works on Firebird, but error -104 on Delphi

IBQuery2.SQL.Add('select l.jb_cdempresa, l.jb_cdfilial, p.dtvencimento, l.jb_cdcontacredito, p.vlrpago,');
        IBQuery2.SQL.Add('l.jb_cdcontacredito, p.vlrpago, f.cnpj_cpf, f.insc_rg,l.cnpj, l.insc,');
        IBQuery2.SQL.Add('from ctaspagar p, lojas l, fornecedores f');
        IBQuery2.SQL.Add('where p.cdloja = l.cdloja');
        IBQuery2.SQL.Add('  and f.cdfornecedor = p.cdfornecedor');
        IBQuery2.SQL.Add('  and p.cdloja = '+(EdLoja.Text)+'');
        IBQuery2.SQL.Add('and p.dtlancamento between :Data_Inicial and :Data_Final');

    IBQuery2.ParamByName('Data_Inicial').Value:= strtoDate(EdDataIni.Text);
    IBQuery2.ParamByName('Data_Final').Value:= strtoDate(EdDataIni.Text);
  • The problem must be in the information that is coming to the Parameter. Remember to evaluate the answers. In your other question there is no evaluation, this is important for future researchers.

1 answer

1


The problem may be in assigning the date parameter. In Firebird the default date is mm/dd/yyyy then...

IBQuery2.ParamByName('Data_Inicial').Value:= FormatDateTime('mm/dd/yyyy', strtoDate(EdDataIni.Text));
IBQuery2.ParamByName('Data_Final').Value:= FormatDateTime('mm/dd/yyyy', strtoDate(EdDataIni.Text));

Remember that this date must be in single quotes, so the parameter should receive:

QuotedStr(FormatDateTime(...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.