title: ADO insert a record into access DB using delphi
body: <p>Am learning how to use insert into statements and, with my access database, am trying to insert a single record.  The table I'm inserting a new record into has three fields: StockID (AutoN), Description (Text), Cost (Number).  I've looked at previous posts but the posted solutions seem to go beyond my basic level of Insert Into...which is what I'm interested in.  Anyway, here is my code...</p>
  
  <pre><code>    adoQuery1.Active := true;
  adoQuery1.SQL.Clear;
  adoQuery1.SQL.Add('INSERT INTO Stock (StockID,Description,Cost) VALUES (4,Cheese,5)');
  adoQuery1.open;
  adoQuery1.Close;
  </code></pre>
  
  <p>It compiles fine, but when press a command button to invoke the above, I get the following message: </p>
  
  <blockquote>
    <p>'ADOQuery1: "Missing SQL property".'</p>
  </blockquote>
  
  <p>what am I doing wrong?</p>
  
  <p>Thanks, Abelisto. Your last post looks complex indeed...but I did my own little version since your last solution got me up and running. It works so I'm very chuffed.  Am now going to focus on DELETE FROM using combobox (for field selection) and user value.  Here was my solution I got working... ;)</p>
  
  <pre><code>x:=strtoint(txtStockID.Text);
  y:=txtDescription.Text;
  z:=strtoCurr(txtCost.Text);
  
  adoQuery1.SQL.Clear;
  adoQuery1.SQL.Add('INSERT INTO tblStock (StockID,Description,Cost)');
  adoQuery1.SQL.Add('VALUES (:StockID,:Description,:Cost)');   // ':StockID' denotes a parameter
  adoQuery1.Parameters.ParamByName('StockID').Value:= x;
  adoQuery1.Parameters.ParamByName('Description').Value:= y;
  adoQuery1.Parameters.ParamByName('Cost').Value:= z;
  adoQuery1.ExecSQL;
  adoQuery1.Close;
  </code></pre>