Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Existance of SQLExpress Instance

Status
Not open for further replies.

Olaf Doschke

Programmer
Oct 13, 2004
14,847
DE
In my company we're working on a foxpro application using a central MS SQL database and some of the installations (but not all) have a local SQLExpress instance. Mostly notebooks, but also "hybrid" stations, eg notebooks with a docking station, used as notebook and workstation.

As I don't know if an SQLExpress instance exists, on startup I simply try to make a connection via sqlstringconnect, but on stations without an SQLExpress instance this takes about 3 seconds and makes the total startup time annoyingly slow, about 6-7 seconds in total. I already lowered the ConnectTimeout to 2 seconds, on a normal station with an SQLExpress installation a connect takes a little more than a second, which also seems rather slow to me, considering it's local.

So my question is, can I quickly find out, if SQLExpress is installed without making a test connection? Would it be reliable looking up a Software key in the registry?

Bye, Olaf.
 
This might do the trick, I gotta try if it's faster at the customers computers next week:

Code:
o = CreateObject("SQLDMO.SQLServer")
llSQLExpress = .F.
For Each lcInstance in o.ListInstalledInstances
   If "\SQLEXPRESS" $ lcInstance
      llSQLExpress = .T.
      Exit
   EndIf
EndFor

? llSQLExpress

Bye, Olaf.
 
Olaf,

Check Re: Enumerating SQL Servers in VFP Thread #1384624 in another VFP related forum.
 
Thanks, I followed the discussion, and now have a couple of things I could try. In my situation I can guarantee SQL Client is installed, as the app surely accesses an SQL Server variant, either SQLExpress locally, SQL Server on the LAN or both.

I will see which gives me the fastest responses to cut down the start time.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top