468,110 Members | 1,583 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

Determine which machine name "(local)" is?


I'm fetching a list of SQL servers on a domain using a function that returns
strings, including "(local)" for the local machine (if it has an SQL server
on it). Now, presumably in a different locale, the word "(local)" will be
something else. I cannot thus compare the string to see if its "(local)"
and replace it with Environment.MachineName. So I need a way of determining
if a given string is the local machine.

ie.:

Dim theString as ConnectionName = GetServerName() ' may return "(local)"

Dim bIsLocal as boolean = somefunc.IsLocal ( theString )

Any ideas?
Thanks

Robin
Nov 21 '05 #1
3 1420
Robin,
You can use "." to mean local also.

Alternatively you can use Environment.MachineName to get the name of the
machine you are on.

For SQL Server I think I would favor "." over Environment.MachineName,
especially in "hard coded" connection strings, as I can use "." at compile
time & not worry about building the string later...

Hope this helps
Jay

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...

I'm fetching a list of SQL servers on a domain using a function that
returns strings, including "(local)" for the local machine (if it has an
SQL server on it). Now, presumably in a different locale, the word
"(local)" will be something else. I cannot thus compare the string to see
if its "(local)" and replace it with Environment.MachineName. So I need a
way of determining if a given string is the local machine.

ie.:

Dim theString as ConnectionName = GetServerName() ' may return "(local)"

Dim bIsLocal as boolean = somefunc.IsLocal ( theString )

Any ideas?
Thanks

Robin

Nov 21 '05 #2
Yes, this is great. Presumably "." is the same in any language!

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
Robin,
You can use "." to mean local also.

Alternatively you can use Environment.MachineName to get the name of the
machine you are on.

For SQL Server I think I would favor "." over Environment.MachineName,
especially in "hard coded" connection strings, as I can use "." at compile
time & not worry about building the string later...

Hope this helps
Jay

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...

I'm fetching a list of SQL servers on a domain using a function that
returns strings, including "(local)" for the local machine (if it has an
SQL server on it). Now, presumably in a different locale, the word
"(local)" will be something else. I cannot thus compare the string to
see if its "(local)" and replace it with Environment.MachineName. So I
need a way of determining if a given string is the local machine.

ie.:

Dim theString as ConnectionName = GetServerName() ' may return "(local)"

Dim bIsLocal as boolean = somefunc.IsLocal ( theString )

Any ideas?
Thanks

Robin


Nov 21 '05 #3
Robin,
As far as I know it is.

Jay
"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...
Yes, this is great. Presumably "." is the same in any language!

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
Robin,
You can use "." to mean local also.

Alternatively you can use Environment.MachineName to get the name of the
machine you are on.

For SQL Server I think I would favor "." over Environment.MachineName,
especially in "hard coded" connection strings, as I can use "." at
compile time & not worry about building the string later...

Hope this helps
Jay

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:cu*******************@news.demon.co.uk...

I'm fetching a list of SQL servers on a domain using a function that
returns strings, including "(local)" for the local machine (if it has an
SQL server on it). Now, presumably in a different locale, the word
"(local)" will be something else. I cannot thus compare the string to
see if its "(local)" and replace it with Environment.MachineName. So I
need a way of determining if a given string is the local machine.

ie.:

Dim theString as ConnectionName = GetServerName() ' may return "(local)"

Dim bIsLocal as boolean = somefunc.IsLocal ( theString )

Any ideas?
Thanks

Robin



Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by jack | last post: by
reply views Thread by Tom Clement | last post: by
3 posts views Thread by Zeljko | last post: by
1 post views Thread by Solo | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.