title: How Can I Sort an ADO Table on a Fieldname Containing a Space?
body: <p>I am using Delphi, but this is a simple and general problem:</p>
  
  <p>I'm doing the following:</p>
  
  <pre><code>var
    ArticlesTable: TADOTable;
  
  begin
    ArticlesTable.DisableControls;
    ArticlesTable.Sort := 'CITY';
    ArticlesTable.First;
    while not ArticlesTable.Eof do begin
      ...
      ArticlesTable.Next;
    end;
  </code></pre>
  
  <p>This works very well and allows me to efficiently process the records one by one with the records ordered ascending by the CITY field as they are coming in.</p>
  
  <p>However, now I wanted to order by the field "LAST NAME" which has an embedded space in it. But when I use the statement:</p>
  
  <pre><code>  ArticlesTable.Sort := 'CITY';
  </code></pre>
  
  <p>I get the error message:</p>
  
  <pre><code>  EOleException:  Arguments are of the wrong type, are out of acceptable range, 
                    or are in conflict with one another.
  </code></pre>
  
  <p>I have seen <a href="http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/ADODB_TCustomADODataSet_Sort.html" rel="nofollow noreferrer">the help on the SORT string syntax</a>. It says to separate multiple fields by commas, and to add ASC or DESC after a field to sort ascending or descending. But it doesn't say what to do if a fieldname has a space in it.</p>
  
  <p>I've tried putting the field name in single and double quotes and even using #20 as the space character, but those don't work.</p>
  
  <p>I can't change the field name on the Microsoft Access database, because there are other programs I don't work with that depend on it.</p>
  
  <p>I'm sure there must be an easy way to do this that I don't know about.</p>