title: How to delete a row from a SQL Server CE Table?
body: <p>I want to delete a record from a SQL Server CE table.</p>
  
  <p>There are 3 tables scripts, options and results. I would like to remove a record from the results table. The where clause contains dynamic information which retrieved via other queries. These queries work fine and deliver the desired data.</p>
  
  <p>The error I get is:</p>
  
  <blockquote>
    <p>There was an error parsing the query. [ Token line number = 1,Token line offset = 25,Token in error = from ]</p>
  </blockquote>
  
  <p>The code that throws the exception is as follows:</p>
  
  <pre><code>Dim connLoc As SqlCeConnection = New SqlCeConnection(My.Settings.ConnectionString)
  connLoc.Open()     
  Dim strDel As String = "Delete ResultsTable from ResultsTable r inner join OptionsTable o ON o.TestName=r.TestName inner join ScriptTable c ON r.TestName=c.TestName WHERE r.TestName = '" &amp; ds1Loc.Tables(0).Rows(0)(1) &amp; "' AND [Index] = '" &amp; lstIndex &amp; "'"
  Dim cmdDel As SqlCeCommand = New SqlCeCommand
  cmdDel.CommandText = strDel
  cmdDel.Connection = connLoc
  cmdDel.ExecuteScalar()
  </code></pre>
  
  <p>The values held in <code>ds1Loc.Tables(0).Rows(0)(1)</code> and <code>lstIndex</code> are correct so should not be the problem.</p>
  
  <p>Also this query works with SQL Server. Is it perhaps that SQL CE does not support the Delete function the same as SQL Server 2008? </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Using Kafs suggested solution below the exception is still the same:</p>
  
  <blockquote>
    <p>There was an error parsing the query. [ Token line number = 1,Token
    line offset = 10,Token in error = from ]</p>
  </blockquote>
  
  <p>The commandText of cmdDel before execution is</p>
  
  <pre><code>Delete r from ResultsTable r inner join OptionsTable o ON o.TestName=r.TestName inner join ScriptTable c ON r.TestName=c.TestName WHERE r.TestName = @TestName AND [Index] = @lstIndex
  </code></pre>
  
  <p><code>@TestName</code> and <code>@lstIndex</code> have values of 'My test' and '3' respectivley. </p>
  
  <p>It may be worth mentioning for anyone reading this in future that I changed 'SQLParameter' to SQLCeParameter as this query is going to a SQL CE Server.</p>