Question

We have a SQL Compact Edition database that we use to store config setting in. It is working fine but I'd like to make changes to it to store additional information.

I am writing in C# using Winforms.

When I make changes to the database in our project, I need to send those changes out to the customer so they have the changes to go with the code changes. Our customers have remote laptops that we have to dial in an manually update. I'd prefer some method that is done automatically in code if possible. I'm not familiar enough with SQLCE to know what tools I have available to make these changes to the customers database. Each remote laptop has it's own SQLCE database with it's own code to access it. They are individual laptops not connected to a network.

What is a simple way to make compare and distribute changes from my project's database and make sure those changes are applied to the customer's database?

Was it helpful?

Solution

It is a common problem. You ship your app with your database, then a new implementation requires a new field in your db (or some other schema change). Now how do you plan to update those customers that have already installed you app and have valuable data inside?

It is a complex task with many details to care of, but at its simplest form could be implemented in this way:

Add, inside you database, a new table with only one record and one column. This table will be called DBVersion, and the record contains a number that reflect the version of the database installed. (If you have a Configuration table you could simply add a record there)

Now you need to prepare an XML file to distribute with your updates

 <Scripts>
    <Script>
      <Version>1</Version>
      <Command>ALTER TABLE ......</Command>
    <Script>
    ....
 <Scripts>

At this point your application could read the Version number stored in your database and load the XML file executing every command associated with a Version number higher than the Version number stored in the database table.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top