Solved

How do I get the name of the server that the DSN connected to?

Posted on 2010-08-15
5
384 Views
Last Modified: 2012-05-10
Hi,

Say, I have two DB Servers(server1 and server2). I have a DSN (Data Source Name) named mydsn. It should be connected to server1. My program should ensure that mydsn is mapped to server1.

How do I get the name of the server that the DSN connected to?

Thank you.
Regin
0
Comment
Question by:Fi-es
5 Comments
 
LVL 7

Expert Comment

by:bclongacre
ID: 33443436
If you are looking specifically to see what server you are getting a response from.

Click Start
Click Run
Type CMD
Press Enter

Type "nslookup", not including quotes, a space then any computer name, IP Address, or web site, and first entry will list the Server queried.

If you want to see what your DNS server settings are you can do the following:

Click Start
Click Run
Type CMD
Press Enter

Type "ipconfig /all" not including quotes then press Enter
0
 
LVL 7

Expert Comment

by:bclongacre
ID: 33443444
My apologies, I had a dyslexic moment, and read DNS as opposed to DSN, and I did not realize it until after I hit the Submit button.
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33443469
you have to connect using the DSN, and then query for the server name:

select @@server

the issue is that even if a "server name" is written in the connection information of the DSN, it could still be an alias.
only connecting and running the above query will give the full instance name actually...
0
 
LVL 4

Expert Comment

by:Audhi203
ID: 33443616
Start -> Control Panel -> Admin Tools -> Data Sources -> Check with the DSN you created if Server name is correct. Also http://support.microsoft.com/kb/138541
0
 

Author Comment

by:Fi-es
ID: 33443748
Thank you all for your help.

Audhi203,
I donot want to manually verify the server. But my program has to ensure if the client machine is connected to the right server.

angelIII,
your solution solves my problem. Your query has a careless mistake.
Right query is
select @@SERVERNAME
I am going to accept your reply as the solution.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 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

23 Experts available now in Live!

Get 1:1 Help Now