Solved

sql directory

Posted on 2002-03-12
9
147 Views
Last Modified: 2012-05-04
how do i get the sql directory..?
(e.g. c:\mssql)
0
Comment
Question by:killer5
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 6859763
Hi killer5, you could try the registry under the following key

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup

The actual executables will be in "Binn" under the directory specified at this key.

HTH:O)Bruintje
0
 
LVL 1

Author Comment

by:killer5
ID: 6859769
how do i get the SQL directory thru VB?
0
 
LVL 3

Expert Comment

by:Rem
ID: 6859823
As bruintje said, read the registry.
you'll need some declarations like:
Option Explicit

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.

Then you'll need a function to open, read and close the registry. For the reading part, something like:
        lngResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup)

Play around with these api calls. Very helpful.

Bye

Rem
0
 
LVL 44

Accepted Solution

by:
bruintje earned 5 total points
ID: 6859832
and of course you could take a look at essentially the same sort of code including a complete get key function at

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=10479&lngWId=1

:O)Bruintje
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Expert Comment

by:Rem
ID: 6859846
Jeez Bruintje, I just woke up, don't ask too much. LOL

I just stripped a bit from my own old stuff looking up the ODBC.INI and changed the string to the one you mentionned.
0
 
LVL 1

Author Comment

by:killer5
ID: 6859908
i don't wanna play around... i'ma  lazy person

can someone give me a function that will search for the SQLPath value in the registry?
0
 
LVL 3

Expert Comment

by:Rem
ID: 6859923
The link bruintje provided gives you what you asked for.
This site is to help people having a specific problem. If you want other people to do your work, or do complete projects, my guess is that you're not on the right website.
Experts gave you what you asked for. So please read the EE guidelines.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6861237
Grade changed.

killer5,

Laziness on your part is no excuse for not rewarding Experts for their assistance, especially when you add questions to the original question without adding points.

Netminder
Community Support Moderator
Experts Exchange
0
 
LVL 44

Expert Comment

by:bruintje
ID: 6861255
;) thanks netminder
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now