views:

95

answers:

2

Is there any way by which we can find programmatically whether SQL Compact is installed or not... Actually I need to know whether the compact edition is installed or not in PC and so that I can include or exclude the SQL Compact dll... Because in my application there are different process that access the same .sdf file which will cause Access Violation error if those dll are included and compact is installed...

Any ideas?

A: 

The best way to do this is to make SQL Compact a requirement of your install process and if its not installed tell the user that they need to install it.You can add the check by setting it as a Prerequisite in the publish section of your projects properties. You can code this manually obviously by checking the default install path for SC but its not the most reliable way.

RC1140
A: 

I would assume a registry check is pretty reliable.

Command

reg query "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5"

Output

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5
    InstallDir    REG_SZ    C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\
    Version    REG_SZ    3.5.5692.0
    NativeDir    REG_SZ    C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\
    ServicePackLevel    REG_DWORD    0x1

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\ENU
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server Compact Edition\v3.5\GAC

You didn't mention the programming language you're using, but if you want to do this from .NET, use the Microsoft.Win32.Registry APIs.

bobbymcr
I'm using C# Ya I'm trying the registry only but at times in some cases the user might not have registry access so is there any other way to trace that out????
jankhana
All users should have permission to **read** HKLM\Software. Writing would of course be restricted to administrators only.
bobbymcr
K i'll use that method and find out thanks for the help
jankhana