Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple database table comparison using DataTable.Merge and DataTable.GetChanges
    primarykey
    data
    text
    <p>We are converting our application from using Sql Server Express (let's call this version 3) to Sql Server Compact Edition (let's call this version 4). I am trying to make sure that upgrades from previous versions (versions 1 and 2) are the same in the new product (version 4) as the old (version 3). The upgrade code had to be rewritten for various reasons.</p> <p>I'm creating a quick test application that will compare a version 3 Sql Server Express database and a version 4 Sql CE database. If the conversion logic is good, the databases should be exactly equivalent--same tables, same columns, same row values.</p> <p>It would seem to me that there should be an easy way to do this using <code>DataTable.Merge</code> and <code>DataTable.GetChanges</code>, but I'm not having success. If rows exist in the version 3 database and not in the version 4 database, the <code>GetChanges</code> still returns null. If there are changes to the same rows (based on the primary key, which is a Guid), <code>GetChanges</code> still returns null.</p> <pre><code>string selectSql = String.Format("SELECT {0} FROM {1}", String.Join(", ", columns.ToArray()), tableName); var expressAdapter = new SqlDataAdapter(selectSql, expressConnection); DataTable expressTable = new DataTable(); expressAdapter.Fill(expressTable); expressTable.PrimaryKey = new DataColumn[] { expressTable.Columns[tableName + "ID"] }; SqlCeConnection ceConnection = new SqlCeConnection(this.SqlServerCeConnectionString); var ceAdapter = new SqlCeDataAdapter(selectSql, ceConnection); DataTable ceTable = expressTable.Clone(); ceAdapter.Fill(ceTable); expressTable.Merge(ceTable); return expressTable.GetChanges(); // this is null even when the expressTable has rows that do not exist in ceTable. </code></pre> <p>Am I using <code>Merge</code> and <code>GetChanges</code> in a way too far removed from their intended use? If so, other options would be welcome.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload