title: Read one value from the last row of a SQL Server CE database
body: <p>I have a database with some columns and one of that is called <code>ID</code> (datatype = <code>int</code>).<br>
  I need to know the value of the <code>ID</code> of the last row (for last row I mean the last created).  </p>
  
  <p>I tried this, but it gives a runtime error:</p>
  
  <pre><code>string query = "SELECT * FROM Customer WHERE ID = (SELECT MAX(ID) FROM Customer)";
  SqlCeCommand comSelect = new SqlCeCommand(query, connection);
  SqlCeDataReader rdr = comSelect.ExecuteReader();
  int ID = rdr.GetInt32(6);
  </code></pre>
  
  <p>(<code>GetInt32(6)</code> because <code>ID</code> is the 6th column)</p>
  
  <p>Thanks all, and sorry for my english.</p>
  
  <p>P.S.</p>
  
  <p>Customer is my table and ID are set in ascending order. The first row created has <code>ID = 0</code> the second <code>ID = 1</code> etc.  </p>
  
  <p>I need to know the last id because when I create a new customer I want to set his <code>ID</code> to previous customer <code>ID+1</code></p>
  
  <p>Errors:</p>
  
  <blockquote>
    <p>Exception of type 'System.Data.SqlServerCe.SqlCeException' in System.Data.SqlServerCe.dll unhandled in user code</p>
  </blockquote>