Replace .SDF database file through .msi upgrade proceed

原文链接:http://www.cnblogs.com/telnet_mike/archive/2012/02/06/2340246.html

http://msdn.microsoft.com/en-us/library/windows/desktop/aa371221(v=vs.85).aspx
Since there's no File Version attribute for the SDF database file for the Existing File replacement policy, but sometimes we really need to replace the SDF file(change the init data, or others things makes you need to replace the database file).
Then we just can edit the .MSI file File table to add the File Version number for the .SDF file, then it can use the Existing File replacement policy:

Then we just need to update the version number once we need to replace the .sdf database file for our product.

Replace .SDF database file through .msi upgrade proceed

Then we can configure the Setup project Post-build Event according to this command to update the msi file:

Cscript WiRunSQL.vbs Setup2.msi "UPDATE `File` SET `File`.`Version`='1.0.0.0' WHERE `File`.`FileName` = 'DATABA~1.SDF|Database1.sdf'"

https://skydrive.live.com/redir.aspx?cid=bb789f72272d4858&resid=BB789F72272D4858!723&parid=BB789F72272D4858!721

[C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiRunSQL.vbs]

I have not found any MSDN document mentioned this way to help our work, this is just based on my experiences and test cases, so please consider carefully before use this way in your product deployment.

ref my Google Blog: http://mikedoszhang.blogspot.com/2012/02/replace-sdf-database-file-through-msi.html

转载于:https://www.cnblogs.com/telnet_mike/archive/2012/02/06/2340246.html

上一篇:日期类型/字符串类型互转


下一篇:时间类型转换