TIBCQuery 4.1
I would be grateful if someone could help with this problem.
I am trying to get back the value of the Autoinc field after an insert.
This is the code I am using. It is just a stripped down version so I can trace what is happening.
Code: Select all
procedure TForm1.BtnTestIDClick(Sender: TObject);
Var NewID : LongWord;
begin
With DM.Qry do begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO Stock(StkCode, StkDesc, StkTaxable)');
SQL.Add('VALUES (') ;
SQL.Add(QuotedStr('Stock Code') + ',');
SQL.Add(QuotedStr('Stock Description') + ',');
SQL.Add('1');
SQL.Add(')');
SQL.Add('RETURNING StkID');
ExecSQL;
end;
NewID := DM.Qry.FieldByName('StkID').AsInteger;
end;
"Qry Field StkID not found"
I have tried "Open" instead of "ExecSQL", but this did not work either.
Thanks
Colin