Goal
I want to determine if the user has SQL Server Express 2014 installed. The version is important to me. I then want to make sure this user has the instance "SQLEXPRESS" on his 2014 server.
Current code
I have a function that returns a boolean value if SQLEXPRESS is installed, but does not take into consideration the version (2008/2010/2012/2014)
Private Function SQLExpressInstalled() As Boolean
Try
Using key As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Microsoft SQL Server\\", False)
If key Is Nothing Then Return False
Dim strNames() As String
strNames = key.GetSubKeyNames
'If we cannot find a SQL server registry key, we don't have SQL Server Express installed
If strNames.Length = 0 Then Return False
If strNames.Contains("SQLEXPRESS") Then
Return True
End If
End Using
Catch ex As Exception
'MsgBox(ex.Message)
End Try
Return False
End Function
Is there a way to pinpoint the version as well as which instance is installed on the given version?