Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > SetUp msi Updating not erasing the MS Database
 

SetUp msi Updating not erasing the MS Database

My project has a ms access database. I need to update my product but not the database. My updated setup msi package removes the previous version together with the database resulting in the clients records being lost. I have tried several setup property combinations without success.

Is there any way of updating without erasing the database?

ClickOnce update can be configured to achieve the desired effect.

latoc
latoc  Monday, July 20, 2009 12:54 PM
VS 2008 setup projects should not remove the database. I'm not sure exactly what you may be doing, but updates to the database after it's first beeninstalled by the originalsetup cause its modify date to change, so a VS 2008 RemovePreviousVersions upgrade should not replace it:

http://msdn.microsoft.com/en-us/library/aa370531(VS.85).aspx

They are the MSI replacement rules. If you're doing something in your own code to copy or replace the DB then obviously these rules don't apply.
Phil Wilson
PhilWilson  Monday, July 20, 2009 10:21 PM
Well it should work. RemovePreviousVersions in a VS 2008 setup project is designed not to replace updated databases. If it's not working, then something is wrong. The rules that make it work are:


ProductCode different between old and new setups.
UpgradeCodes the same.
Version in the newer Setup project higher than in the older setup.
All Versionproperties of the setup project >= 1.0
Both products installed the same way, both Just me or both Everyone.

Phil Wilson
PhilWilson  Tuesday, July 21, 2009 10:38 PM

This is something you need to plan before you release the first version of your application. If you're doing an MSI Major Upgradethen the uninstall that is running (to remove the previous version) runs from the cached MSI package on the target system (the original install). If you didn't plan for that MSI package to be able to be uninstalled and leave behind customer data (such as the MS Access database you mention) then youhave a few options (see suggestions below). For more information on MSI upgrades see the Patching and UpgradesMSDN topic.

If you have data that may or may not need to be maintained between major upgrades, always plan the uninstall of the MSI package so that whatever actions remove the data can be skipped when updating (use the UPDATINGPRODUCTCODEproperty in the conditional statement for the action) or make the default behavior to leave this information and give the user an option to override it during uninstall.

Option 1: Don't do a major upgrade.
Keep the same ProductCode and make your update a minor upgrade.

Option 2: Fix the cached MSI database.
2a) One way to do this would be torelease a patch that modifes the cached database to add the 'NOT UPDATINGPRODUCTCODE' condition to the action that removes the database. However, that would require cusotmers to first apply the patch. If you have a bootstrapper/launcher application (setup.exe) that can handle running the patch before launching your major update then you can ship the patch with your major update and make it easier for customers to deal with the update scenario.

2b) Create a custom action to update the cached MSI database and sequence it before the RemoveExistingProducts action.

Option 3:
Create a custom action to save the user data and sequence it before the RemoveExistingProducts action and another CA to run afterwards that restores the saved information.

Option 4:
Prompt your users to make a copy of the database before running the upgrade and to restore the saved database after the upgrade.

ColbyRingeisen  Monday, July 20, 2009 3:24 PM

Thank you for your detailed response. As I am sure it’s obvious this is my first attempt. I will research the links relating to minor/patch updates. What do you mean �‘Fix chached MSI database? My database has been added to the root of the application.

Regards latoc

latoc  Monday, July 20, 2009 5:03 PM
If you're using a VS 2005 setup project this is the way RemovePreviousVersions works. VS 2008 setup projects do not have this behavior.
Phil Wilson
PhilWilson  Monday, July 20, 2009 7:56 PM

Thanks for the info. Yes I am using VS2008. To avoid me going down ‘blind alleys�am I correct in assuming that VS2008 SetUp msi does not support the required updating method?

latoc

latoc  Monday, July 20, 2009 8:35 PM
VS 2008 setup projects should not remove the database. I'm not sure exactly what you may be doing, but updates to the database after it's first beeninstalled by the originalsetup cause its modify date to change, so a VS 2008 RemovePreviousVersions upgrade should not replace it:

http://msdn.microsoft.com/en-us/library/aa370531(VS.85).aspx

They are the MSI replacement rules. If you're doing something in your own code to copy or replace the DB then obviously these rules don't apply.
Phil Wilson
PhilWilson  Monday, July 20, 2009 10:21 PM

I have researched the suggested links and tried many configurations without the appropriate result.

What I am trying to achieve using SetUp msi is to update my application after first installation (which contains an ms access database in the root of the project) without coping or overwriting the database.

I have tested combinations of the SetUp properties i.e. version, productcode, upgradecode, removeprevious versions, but the previous version complete with database is removed and replace, thereby losing all recorded data

I am not using any code only the built in features of SetUp.

Is it possible using VS 2008 SetUp to achieve, say for example, the similar update results available using ClickOnce?

latoc

latoc  Tuesday, July 21, 2009 9:50 PM
Well it should work. RemovePreviousVersions in a VS 2008 setup project is designed not to replace updated databases. If it's not working, then something is wrong. The rules that make it work are:


ProductCode different between old and new setups.
UpgradeCodes the same.
Version in the newer Setup project higher than in the older setup.
All Versionproperties of the setup project >= 1.0
Both products installed the same way, both Just me or both Everyone.

Phil Wilson
PhilWilson  Tuesday, July 21, 2009 10:38 PM

Thank you for your conformation and settings. I have not yet found what’s wrong but I will persist. I will post the result as it may be of help to others.

latoc

latoc  Wednesday, July 22, 2009 9:07 PM

You can use google to search for other answers

Custom Search

More Threads

• application not running on computers without vb .net installed
• Deployment Startup Name and Directory
• Isolated property "not imported" failure
• Silent install of setup.exe failed.
• what functionality should be included in the client download?
• Silent ClickOnce update
• Unable to write to a file on the installation
• Appupdater Woes......
• clickonce error when using clickonce api's (error provider element is missing?)
• Access To File Path Denied Error