The best way to check if SQL CE is installed, and if so what version?

亡梦爱人 提交于 2019-12-05 17:16:45

The widely accepted method for doing this is checking the product identifier (GUID) which is saved in the registry by the MSI installer. If you dont have the product in question installed you can crack open the MSI with a tool called Orca (part of Windows SDK) and grab the GUID that way. Most if not all install builders have an action or task that can do this as part of a pre-req test, even VS2005/2008 has this capability.

To check versions, I would dig around again in the registry or maybe look at file versions.

Not sure if you are talking about SQL CE on a Windows machine or a portable device. On a PC, your best bet is to distribute the version of SQL CE with your application. You can register for the rights to do so at http://www.microsoft.com/Sqlserver/2005/en/us/compact-redistribute.aspx.

As BlackWasp pointed out, the best way is to distribute the SqlServerCe- assembly with your application. If you want to check which version a database file (SDF file) is, you should look here.

Hope this helps.

This is my solution. It added 5 megs to my installation file, but it now also installs offline. It takes a couple extra seconds to install, but it always does the right thing.

Why this should be the defacto solution:

  • Insuring that a program is installed properly should be the responsibility of the installer of that feature
  • You ALWAYS want the end result to be that SQL Server CE is installed (even if the user pissed around with the original installation)
  • It's only 5 megs extra(but you could still use downloading)

        DownloadUrl="http://download.microsoft.com/download/0/5/D/05DCCDB5-57E0-4314-A016-874F228A8FAD/SSCERuntime_x86-ENU.exe"
        SourceFile="SSCERuntime_x86-ENU.exe"
        Compressed="no"
    

This is my solution:

<PackageGroup Id="SQLExpressCE">
  <ExePackage
        Vital="yes"
        SourceFile="SSCERuntime_x86-ENU.exe"
        InstallCondition="NOT VersionNT64"

        //Include the exes(only about 2.5 megs each)
        //Setting this to no causes your bootstrapper to download on installation but since this will always be trying to install, it is probably best to include it
        Compressed="yes"

        //install quietly without an interface
        InstallCommand="/i /quiet /n"
        />
  <ExePackage
        Vital="yes"
        InstallCondition="VersionNT64" 
        SourceFile="SSCERuntime_x64-ENU.exe"
        Compressed="yes"
        InstallCommand="/i /quiet /n"
        />
</PackageGroup>

OK, this only answers the first part of your question, but hope it's useful anyway... This is what I currently use:

<Fragment>
    <util:RegistrySearch
          Id='SearchForSQLCE'
          Variable="SQLCEInstalled"
          Result="exists"
          Root="HKLM"
          Key="SOFTWARE\Classes\Microsoft SQL Server Compact Edition Database File"
          Win64="yes"
               />
  </Fragment>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!