How to check in c# code if LocalDB currently installed? also, how to check if SQLNCLI11 presents in system?
C:\Program Files\Microsoft SQL Server\MSSQL{nn}.
Check if LocalDB is installed, by looking for this registry key:
[HKLM\SOFTWARE\Microsoft\Microsoft SQL Server Local DB\Installed Versions\11.0]
SQLNCLI11 - check the file version and presence of this file: C:\WINDOWS\system32\sqlncli.dll
Here is a VB.NET example checking for LOCALDB
Public Shared Function CheckLocalDBExists() As Boolean Dim s As String = "" Dim reg As RegistryKey Dim rtn As Boolean = False reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Microsoft SQL Server Local DB\Installed Versions\12.0", True) Try s = reg.GetValue("ParentInstance", "").ToString reg.Close() Catch ex As Exception s = Nothing End Try 'MessageBox.Show(s) If s = "MSSQL12E.LOCALDB" Then rtn = True End If Return rtn End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With