Link to home
Start Free TrialLog in
Avatar of Tegwin15
Tegwin15

asked on

Finding Local SQL server Visual Baisc

I am looking to write a program that uses SQL server or MSDE. I would like to know if there anyway that I can detect if MSSQL/MSDE is installed on the local machine. and if so then just create the databases and if not then install MSDE. Does anyone know how I can do this.

Avatar of twalgrave
twalgrave

Several methods actually.  Registry, looking for the file, etc.  See here for some details:
http://www.mysql.com/doc/en/Windows_prepare_environment.html
(Scroll down because the page is designed poorly)
Avatar of Tegwin15

ASKER

Thanks for this but I am actually looking for information on how to decect MS SQL server and NOT MySQL. Thanks
Also this is with Visual Basic. I forgot to mention
Sorry bout that:  You can check in the registry for SQL Server as well.

Version Using the HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServer\Setup\ProductSuite key you can determine the version of SQL Server you are running.
SQL Server 6.x standard versions = No entry (There should be NO ProductSuite key)
SQL 6.5 Enterprise Edition = Enterprise
Small Business Server = SBS

SQL Server Keys the keys SQL Server uses are as follows:
Generic to all versions:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSSQLServer
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer
Specific to 6.0

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MSDTC
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SQLExecutive
Specific to 7.0

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SQLServerAgent
HKEY_LOCAL_MACHINE\Software\Microsoft\Microsoft SQL Server 7
HKEY_LOCAL_MACHINE\Software\Microsoft\MSSQLServ65
Also this is with Visual Basic. I forgot to mention
So does this mean you need help in reading the registry keys via VB?  If so, you can look into the following:
http://www.ilook.fsnet.co.uk/vb/vbreg.htm
being new her you may not realize that using the refresh facility of your browser after posting a comment will post it twice.  Use the "Reload this question" at the top left of the page to refresh instead.
Excellent twalgrave, I am very new to VB, so i am sure I will be able to understand your code. I will come back if I need more. Thanks for your help
Glad to help out.

No problem leaving this open for now, but don't forget to come back to finalize it at some point.  If this is your first foray into APIs using VB, you might need some help and I'm here for that, just post here.  The site has been experiencing some email outages recently and that's the only way I know when you respond, but I will always respond back even if to say "I don't know" so if I don't respond, it's probably due to email notifications being down again.
I tad a look at your code the registry stuff and I managed to get it to read the registry, which is good. But what if the key is not there (i.e if MSSQL is not installed ?) what would be returned then. Also I would like to have something that returns eg (MS SQL server version 8.0 Enterprize edition, Service Pack 3. I have seen some apps that do this, which i believe use something called SQL-DMO ? Do you know anything about this. It is still very helpful to have the registry thing ..



ASKER CERTIFIED SOLUTION
Avatar of twalgrave
twalgrave

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok this is clear. I will give it a bash and see how it goes.