SQL Statement in Delphi throwing "missing semi-colon" error

106 Views Asked by At

I am pulling data into a new MS Access database from a previous Access database. I am inserting old transaction data into the new table using a SQL statement which looks correct and will work in MS Access directly, but when I execute it in Delphi (5) I get an OLE error stating that there is a missing semi-colon at the end of the statement. I have hunted through all the answers to similar questions on several sites, but nothing seems to be relevant to this problem. I'd be grateful if someone could cast an eye over the code and the statement and perhaps spot my error.

    with InsertQuery do begin
        Close;
        SQLStr := 'insert into trans (Transactionid, saleid,productcode, barcode, description, salequantity, price,';
        SQLStr := SQLStr + 'SalePrice, category, transdate, taxrate, receiptText) values (';
        SQLStr := SQLStr + IntToStr(TransNo)+','+IntToStr(SaleNo)+','+QuotedStr(PCode)+','+QuotedStr(Bcode)+','+QuotedStr(Desc)+',';
        SQLStr := SQLStr + IntToStr(Qty)+','+FloatToStrF(PPrice,ffFixed,10,2)+','+FloatToStrF(PPrice,ffFixed,10,2)+',';
        SQLStr := SQLStr + QuotedStr(Cat)+','+FormatDateTime('#'+'yyyy-mm-dd'+'#',sDate)+',';
        SQLStr := SQLStr + QuotedStr('E')+','+QuotedStr(RText)+')';
        SQL.Add(SQLStr);
        ExecSQL;
     end;

Here is the query generated above. Taken from inspection of the variable SQLStr:

insert into trans (transactionid, saleid, productcode, barcode, salequantity, price, saleprice, 
category, transdate, taxrate, receiptText) values (2728,1034,'BPG 27/03/2020','BPG 27/03/2020',1,8.00,8.00,'Clubs and Classes',#2019-08-23#,'E','BPGroup 27/03/2020')

As I stated above, running the query above in Access works fine.

Any help, pointers very much appreciated. Thank you.

0

There are 0 best solutions below