views:

1850

answers:

3

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

+2  A: 

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.

BlackWasp
A: 

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.

ollifant
+1  A: 

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.

Davo