Question

I've written a VB.NET application that uses SQL CE 3.5. I'm curious if anyone has any best practice or code to help check if A) SQL CE is installed and B) If so, what version.

I searched msdn and google for anything but I didn't find anything helpful. I was poking around the registry and found this key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5 with a string value "Version" and the data was 3.5.5692.0.

So off the bat my assumption is to check for the presence of this key but it bothers me because the "3.5" key sure sounds like it's tied to the 3.5 DLL. What I'm trying to say is I'd hate to force someone to install SQL 3.5 if they have SQL CE (insert some future version of CE here).

Misc info: Target Framework: .NET 2.0 Minimum Target OS: Windows XP SP2

Was it helpful?

Solution

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.

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top