[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

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

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
Fi-es
Asked:
Fi-es
1 Solution
 
bclongacreCommented:
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
 
bclongacreCommented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
Audhi203Commented:
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
 
Fi-esAuthor Commented:
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now