?
Solved

Getting the server name from a DSN

Posted on 2003-03-21
6
Medium Priority
?
163 Views
Last Modified: 2010-05-18
Hi all,

How can I get the server name given a SQLServer DSN?
How can I get the database path of an Access DSN?

I suppose that odbc32.dll could help me, but I don't know
the right function to call from my Visual Basic .Net program.

Thanks in advance
0
Comment
Question by:JotaEme
[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
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:twalgrave
ID: 8198710
0
 

Author Comment

by:JotaEme
ID: 8201162
Hi again,

Thank you very much for the information, nevertheless, I'm
afraid it's not what I need :-(

This code shows the System and User DSNs, and what I want
is to retrieve the SQLServer name given a DSN name.
I already use a piece of code similar to the one
provided by you in order to fill up a combo box, but what
I need is to know which is the server name of the DSN
selected by the user.

If possible, I would also like to know the path of the Access file (in case the DSN represented an Access one).

Best regards
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 8206209
Sorry, I sent you the wrong link, it was the next link in the sequence.  Here's the sample I meant to send:
http://www.mvps.org/vbnet/index.html?code/system/sqldatasources.htm

This is only a sample and still the native code doesn't show you how to retrieve what you want, but does show you the methods to retrieve the ODBC data sources and obtain some info fromt he registry.  With that in mind, you can get to the following Registry areas to get your DB location info:

HKEY_CURRENT_USER\Software\ODBC\ODBC.INI\DSNNAME\DBQ

Where DSNNAME is the name of the DSN you are looking for.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:JotaEme
ID: 8208814
Thanks again,

What you mean is that I have to work with the registry, don't you?.

I have already had a look at the registry, but my concern is: is the registry structure the same regarless your O.S. and the versions of the drivers?

If not, my applications won't work propery in a different O.S. or using a different version of the ODBC drivers, am I wrong?

Bye
0
 
LVL 16

Accepted Solution

by:
twalgrave earned 200 total points
ID: 8209658
The registry settings for the DSNs has remained intact across all versions that I have worked with.  Unfortunately, I don't have XP, but it should be a simple matter of finding an XP box and checking to see if the registry locations are the same.  Also, it's been a while for me with 95/98, but these might have stored the DSN info into the ODBC.INI file.  The GetPrivateProfileString API can be used in this circumstance.
0
 

Expert Comment

by:CleanupPing
ID: 9446916
JotaEme:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Progress
Starting up a Project
Suggested Courses

777 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