?
Solved

Finding Local SQL server Visual Baisc

Posted on 2003-02-24
12
Medium Priority
?
224 Views
Last Modified: 2013-12-04
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.

0
Comment
Question by:Tegwin15
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 16

Expert Comment

by:twalgrave
ID: 8009440
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)
0
 

Author Comment

by:Tegwin15
ID: 8009545
Thanks for this but I am actually looking for information on how to decect MS SQL server and NOT MySQL. Thanks
0
 

Author Comment

by:Tegwin15
ID: 8009576
Also this is with Visual Basic. I forgot to mention
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:twalgrave
ID: 8009595
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
0
 

Author Comment

by:Tegwin15
ID: 8009613
Also this is with Visual Basic. I forgot to mention
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 8009638
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
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 8009648
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.
0
 

Author Comment

by:Tegwin15
ID: 8009931
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
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 8009995
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.
0
 

Author Comment

by:Tegwin15
ID: 8012340
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 ..



0
 
LVL 16

Accepted Solution

by:
twalgrave earned 200 total points
ID: 8013177
You will receive one of the following if the key isn't there or doesn't match what you expect to find:

Private Const ERROR_NONE = 0
Private Const ERROR_BADDB = 1
Private Const ERROR_BADKEY = 2
Private Const ERROR_CANTOPEN = 3
Private Const ERROR_CANTREAD = 4
Private Const ERROR_CANTWRITE = 5
Private Const ERROR_OUTOFMEMORY = 6
Private Const ERROR_INVALID_PARAMETER = 7
Private Const ERROR_ACCESS_DENIED = 8
Private Const ERROR_INVALID_PARAMETERS = 87
Private Const ERROR_NO_MORE_ITEMS = 259

So if the return value from the call returns 0, you have successfully read the value.

Here's some SQL-DMO examples form Microsoft:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sqldmo/dmoref_ex01_50vj.asp

http://msdn.microsoft.com/library/en-us/sqldmo/dmoref_ex01_7gxl.asp
0
 

Author Comment

by:Tegwin15
ID: 8016057
Ok this is clear. I will give it a bash and see how it goes.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't know how to downgrade, my instructions below should be helpful.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question