title: Updating a record in database
body: <ul>
  <li>Using <code>TADOCommand</code> to update a record.</li>
  <li>using <code>TADOCommand</code> to insert a new record.</li>
  <li>Name of table is <code>Board</code></li>
  <li>Using MS Access database</li>
  </ul>
  
  <p>I get an error </p>
  
  <blockquote>
    <p>Syntax error in UPDATE/INSERT INTO statement</p>
  </blockquote>
  
  <p>I can connect and retrieve data just fine. Just never added or updated data before. </p>
  
  <p>My database columns looks like this</p>
  
  <pre><code>ID (auto number)   
  SN (text)  
  CardType (text)  
  Desc (memo)  
  dbDate (date)  
  Tech (text)
  </code></pre>
  
  <p>Code looks like this:</p>
  
  <pre><code>procedure TForm2.BSaveClick(Sender: TObject);
  const
     sqlStringNew = 'INSERT INTO Board (SN,CardType,Desc,dbDate,Tech) VALUES (:aSN,:aCardType,:aDesc,:aDate,:aTech);';
     sqlStringUpdate = 'UPDATE Board SET SN=:aSN, CardType=:aCardType, Desc=:aDesc, dbDate=:aDate, Tech=:aTech WHERE ID = :aID;';
  var
    ADOCommand : TAdoCommand;
  begin
    ADOCommand := TADOCommand.Create(nil);
  
     // updating a board
     if NewBoard = false then
     begin
        try
          ADOCommand.Connection := adoConnection1;
          ADOCommand.Parameters.Clear;
          ADOCommand.Commandtext := sqlStringUpdate;
          ADOCommand.ParamCheck := false;
          ADOCommand.Parameters.ParamByName('aSN').Value := ESerialNumber.Text;
          ADOCommand.Parameters.ParamByName('aCardType').Value := ECardType.Text;
          ADOCommand.Parameters.ParamByName('aDesc').Value := MDescription.Text;
          ADOCommand.Parameters.ParamByName('aDate').Value := strtodate(EDate.Text);
          ADOCommand.Parameters.ParamByName('aTech').Value := ETech.Text;
          ADOCommand.Parameters.ParamByName('aID').Value := UpdateID;
          ADOCommand.Execute;
        finally
          ADOCommand.Free;
        end;
        Showmessage('Update Complete');
     end;
  
    //if a new board
    if NewBoard = True then
      Begin
        try
          ADOCommand.Connection := adoConnection1;
          ADOCommand.Parameters.Clear;
          ADOCommand.Commandtext := sqlStringNew;
          ADOCommand.ParamCheck := false;
          ADOCommand.Parameters.ParamByName('aSN').Value := ESerialNumber.Text;
          ADOCommand.Parameters.ParamByName('aCardType').Value := ECardType.Text;
          ADOCommand.Parameters.ParamByName('aDesc').Value := MDescription.Text;
          ADOCommand.Parameters.ParamByName('aDate').Value := strtodate(EDate.Text);
          ADOCommand.Parameters.ParamByName('aTech').Value := ETech.Text;
          ADOCommand.Execute;
        finally
          ADOCommand.Free;
  
        end;
        NewBoard := false;
        BSave.Enabled := false;
        NoEdit;
        Showmessage('New Record Added');
      End;
  end;
  </code></pre>