Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL statement problem

Status
Not open for further replies.

tag141

Technical User
Oct 4, 2003
119
AU
I have an application that I want to use for keeping a track of stock. I have this code but it keeps giving the exception 'syntax error in update statement' I cannot for the life of me work out which bit is the error.

Code:
procedure TForm1.Button4Click(Sender: TObject);     //update button
var
  d: TDate;
  DateToStr: string;
begin

If code.Text = '1234'  then
ShowMessage('Now is  ' + DateTimeToStr(Now));
begin
DateToStr := FormatDateTime ( 'dd/mm/yyyy', d );
    with ADOQuery1 do
begin
    Active:=False;
    SQL.Clear;
    SQL.Add('UPDATE tblStock SET bottle =' + QuotedStr(code.text) + ', quantity = quantity+5, WHERE reagname = "AST"');
    ExecSQL;
end;
end;
end;
It 'should' update the field bottle (which is text) and quantity (which is number). Any ideas why it gives this message?

TIA
 
It's always a good idea to test your SQL queries outside of your Delphi code first. Database Explorer is shipped with the version of Delphi I use (accessible via the "Explore" menu item in the "Database" menu) and this application can be used to open a database table and execute SQL queries on it.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top