title: Delphi - reading the records of a database into a string grid
body: <p>So how do you write the records of a database (from a TADOTable component) into a String grid? (the record's fields are all strings)</p>
  <p>I tried something like this but to no avail:</p>
  <pre><code>procedure TfrmPuntehou.WriteToList(tbl: TADOTable;grid:TStringGrid);
  var
    iNewRowCount:integer;
    i,j,m: Integer;
    const
    separator = ',';
  begin
    tempList:= TStringList.Create;
    try
      tbl.First;
      while not (tbl.Eof) do
      begin
        tempList.Add(tbl['Car Number']+separator+tbl['Racer Name']+separator+tbl['Licence']);
        tbl.Next;
      end;
          for j:= 1 to (tempList.Count - 1) do
        begin
        grid.Rows[j].Text := tempList.Strings[(J-1)] ;
        end;
    finally
     tempList.Free;
    end;
  
        //fill the row numbers
        for m := 1 to grid.rowcount do
        begin
        grid.Cells[0,m]:= IntToStr(m);
        end;
  end;
  </code></pre>
  <p>Example of the output I'm trying to get on startup: (Row number column is not part of the db) <br>
  <a href="https://i.stack.imgur.com/tZfqG.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tZfqG.jpg" alt="enter image description here" /></a></p>
  <p>Thanks in advance for the help!
  <br>
  Kind Regards<br>
  PrimeBeat</p>