Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Detect sql server 2008 (Express)

Detect sql server 2008 (Express)

Scheduled Pinned Locked Moved Database
questioncsharpdatabasesql-serverdotnet
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    spif2001
    wrote on last edited by
    #1

    Hi First of all I have to say, that I'm in no way an SQL expert more likely an SQL dummy, so be warned. :) I'm am currently building an InnoSetup installer hierarchy and as a part of that I have made a prerequisite downloader+installer for various Microsoft items - .NET Frameworks, Windows Installers, Internet Explorers, MDAC etc. To detect the various components I use mostly registration keys, but as I played around with SQL Server 2005 Express I found out, that registration keys wasn't a good way detect it. Instead I tried creating an Ole object like this:

    function SQLServerExpress2005Exist(): Boolean;
    begin
    Result := True;
    try
    SQLServer := CreateOleObject('SQLDMO.SQLServer');
    except
    if MsgBox(CustomMessage('SQLServerExpress2005Msg'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then Result := False;
    end;
    end;

    This method works when trying to detect an SQL Server 2005, but when I try using the same method on my computer with a running SQL Server 2008 Express, it doesn't work i.e. the code enters the except block. What is the best way to detect an installed (not necessarily running) SQL Server 2008?

    I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

    T 1 Reply Last reply
    0
    • S spif2001

      Hi First of all I have to say, that I'm in no way an SQL expert more likely an SQL dummy, so be warned. :) I'm am currently building an InnoSetup installer hierarchy and as a part of that I have made a prerequisite downloader+installer for various Microsoft items - .NET Frameworks, Windows Installers, Internet Explorers, MDAC etc. To detect the various components I use mostly registration keys, but as I played around with SQL Server 2005 Express I found out, that registration keys wasn't a good way detect it. Instead I tried creating an Ole object like this:

      function SQLServerExpress2005Exist(): Boolean;
      begin
      Result := True;
      try
      SQLServer := CreateOleObject('SQLDMO.SQLServer');
      except
      if MsgBox(CustomMessage('SQLServerExpress2005Msg'), mbConfirmation, MB_YESNO or MB_DEFBUTTON2) = IDYES then Result := False;
      end;
      end;

      This method works when trying to detect an SQL Server 2005, but when I try using the same method on my computer with a running SQL Server 2008 Express, it doesn't work i.e. the code enters the except block. What is the best way to detect an installed (not necessarily running) SQL Server 2008?

      I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

      T Offline
      T Offline
      Tamer Oz
      wrote on last edited by
      #2

      try System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources(); :)

      S 1 Reply Last reply
      0
      • T Tamer Oz

        try System.Data.Sql.SqlDataSourceEnumerator.Instance.GetDataSources(); :)

        S Offline
        S Offline
        spif2001
        wrote on last edited by
        #3

        That looks like a .NET library and I can't use .NET in InnoSetup - not directly anyway and I can't be sure of which .NET version is on the target machine, and if it has one at all. InnoSetup code is written in Pascal, so what I really need is a Pascal way of doing the check. :)

        I'm in the high-fidelity first class traveling set. And I think I need a Lear jet.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups