可能是关于Environment.MachineName的愚蠢问题 [英] Possibly dumb question about Environment.MachineName

查看:102
本文介绍了可能是关于Environment.MachineName的愚蠢问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚从一位剩下

的同事手中维护了一个系统。我在她的代码中找到以下行:


Dim params(2)As SqlClient.SqlParameter


params(0)=新的SqlClient。 SqlParameter(" @ UserName",pvstrUsername)

params(1)= New SqlClient.SqlParameter(" @ Password",pvstrPassword)

params(2)= New SqlClient.SqlParameter(" @ MachineName",

Environment.MachineName())

当我在调试器中运行代码时,我发现该值

Environment.MachineName与我的PC名称相同。但是我在我的localhost IIS上运行它是



所以,我的问题是:如果我在我的浏览器中运行它但是使用

应用程序在不同的Web服务器上,

Environment.MachineName的价值是什么?


我能说清楚吗?我和一袋扳手一样愚蠢吗?


爱德华

-

阅读小组的阅读小组:
http://www.bookgroup.org.uk

解决方案

爱德华,


这是服务器端代码。它将产生服务器的名称。


Eliyahu


" Edward" < TE ******** @ hotmail.com>在消息中写道

news:25 ************************* @ posting.google.co m ... < blockquote class =post_quotes>我刚从一位已经离开的同事那里接管了一个系统。我在她的代码中找到以下行:

Dim params(2)As SqlClient.SqlParameter

params(0)= New SqlClient.SqlParameter(" @ UserName", pvstrUsername)
params(1)= New SqlClient.SqlParameter(" @ Password",pvstrPassword)
params(2)= New SqlClient.SqlParameter(" @ MachineName",
Environment。 MachineName())

当我在调试器中运行代码时,我发现
Environment.MachineName的值与我的PC名称相同。但是我在我的localhost IIS上运行它。

所以,我的问题是:如果我在浏览器中运行它,但在不同的Web服务器上使用
应用程序,
Environment.MachineName的价值是什么?

我能说清楚吗?我和一袋扳手一样愚蠢吗?

爱德华
-
阅读小组的阅读小组:
http://www.bookgroup.org.uk


Environment.MachineName没有获取您所使用的Web服务器的名称,但是您所在的计算机的名称。您甚至可以在
$ b中使用它。 $ b Windows窗体。所以不管它给你什么电脑的名字。

在MSDN中查看此链接以获得正确的定义
http://msdn.microsoft.com/library/de...us/cpref / html /

frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz

MCT; MCSD,MCDBA

无国界医生执业者


" Edward" < TE ******** @ hotmail.com> escribióenel mensaje

news:25 ************************* @ posting.google.co m ...

我刚从一位已经离开的同事那里接管了一个系统。我在她的代码中找到以下行:

Dim params(2)As SqlClient.SqlParameter

params(0)= New SqlClient.SqlParameter(" @ UserName", pvstrUsername)
params(1)= New SqlClient.SqlParameter(" @ Password",pvstrPassword)
params(2)= New SqlClient.SqlParameter(" @ MachineName",
Environment。 MachineName())

当我在调试器中运行代码时,我发现
Environment.MachineName的值与我的PC名称相同。但是我在我的localhost IIS上运行它。

所以,我的问题是:如果我在浏览器中运行它,但在不同的Web服务器上使用
应用程序,
Environment.MachineName的价值是什么?

我能说清楚吗?我和一袋扳手一样愚蠢吗?

爱德华
-
阅读小组的阅读小组:
http://www.bookgroup.org.uk


Environment.MachineName没有获取您所使用的Web服务器的名称,但是您所在的计算机的名称。您甚至可以在
$ b中使用它。 $ b Windows窗体。所以不管它给你什么电脑的名字。

在MSDN中查看此链接以获得正确的定义
http://msdn.microsoft.com/library/de...us/cpref / html /

frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz

MCT; MCSD,MCDBA

无国界医生执业者


" Edward" < TE ******** @ hotmail.com> escribióenel mensaje

news:25 ************************* @ posting.google.co m ...

我刚从一位已经离开的同事那里接管了一个系统。我在她的代码中找到以下行:

Dim params(2)As SqlClient.SqlParameter

params(0)= New SqlClient.SqlParameter(" @ UserName", pvstrUsername)
params(1)= New SqlClient.SqlParameter(" @ Password",pvstrPassword)
params(2)= New SqlClient.SqlParameter(" @ MachineName",
Environment。 MachineName())

当我在调试器中运行代码时,我发现
Environment.MachineName的值与我的PC名称相同。但是我在我的localhost IIS上运行它。

所以,我的问题是:如果我在浏览器中运行它,但在不同的Web服务器上使用
应用程序,
Environment.MachineName的价值是什么?

我能说清楚吗?我和一袋扳手一样愚蠢吗?

爱德华
-
阅读小组的阅读小组:
http://www.bookgroup.org.uk


I''ve just taken over maintaining a system from a colleague who has
left. I find the following line in her code:

Dim params(2) As SqlClient.SqlParameter

params(0) = New SqlClient.SqlParameter("@UserName", pvstrUsername)
params(1) = New SqlClient.SqlParameter("@Password", pvstrPassword)
params(2) = New SqlClient.SqlParameter("@MachineName",
Environment.MachineName())

When I run the code in the debugger, I find that the value of
Environment.MachineName is the same as the name of my PC. But I''m
running this on my localhost IIS.

So, my question is: if I run this in my browser but with the
application on a different web server, what will the value of
Environment.MachineName?

Do I make myself clear? Am I as dumb as a bag of spanners?

Edward
--
The reading group''s reading group:
http://www.bookgroup.org.uk

解决方案

Edward,

It''s a server-side code. It will produce the server''s name.

Eliyahu

"Edward" <te********@hotmail.com> wrote in message
news:25*************************@posting.google.co m...

I''ve just taken over maintaining a system from a colleague who has
left. I find the following line in her code:

Dim params(2) As SqlClient.SqlParameter

params(0) = New SqlClient.SqlParameter("@UserName", pvstrUsername)
params(1) = New SqlClient.SqlParameter("@Password", pvstrPassword)
params(2) = New SqlClient.SqlParameter("@MachineName",
Environment.MachineName())

When I run the code in the debugger, I find that the value of
Environment.MachineName is the same as the name of my PC. But I''m
running this on my localhost IIS.

So, my question is: if I run this in my browser but with the
application on a different web server, what will the value of
Environment.MachineName?

Do I make myself clear? Am I as dumb as a bag of spanners?

Edward
--
The reading group''s reading group:
http://www.bookgroup.org.uk



Environment.MachineName does not get the name of the web server you are
runnnig on but the name of the computer you are in. You could even use it in
Windows Forms. So no matter what it will give you the name of the PC.
Check this link in MSDN for the proper definition
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...

I''ve just taken over maintaining a system from a colleague who has
left. I find the following line in her code:

Dim params(2) As SqlClient.SqlParameter

params(0) = New SqlClient.SqlParameter("@UserName", pvstrUsername)
params(1) = New SqlClient.SqlParameter("@Password", pvstrPassword)
params(2) = New SqlClient.SqlParameter("@MachineName",
Environment.MachineName())

When I run the code in the debugger, I find that the value of
Environment.MachineName is the same as the name of my PC. But I''m
running this on my localhost IIS.

So, my question is: if I run this in my browser but with the
application on a different web server, what will the value of
Environment.MachineName?

Do I make myself clear? Am I as dumb as a bag of spanners?

Edward
--
The reading group''s reading group:
http://www.bookgroup.org.uk



Environment.MachineName does not get the name of the web server you are
runnnig on but the name of the computer you are in. You could even use it in
Windows Forms. So no matter what it will give you the name of the PC.
Check this link in MSDN for the proper definition
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemenvironmentclassmachinenametopic.asp

Alan Ferrandiz
MCT;MCSD,MCDBA
MSF Practitioner

"Edward" <te********@hotmail.com> escribió en el mensaje
news:25*************************@posting.google.co m...

I''ve just taken over maintaining a system from a colleague who has
left. I find the following line in her code:

Dim params(2) As SqlClient.SqlParameter

params(0) = New SqlClient.SqlParameter("@UserName", pvstrUsername)
params(1) = New SqlClient.SqlParameter("@Password", pvstrPassword)
params(2) = New SqlClient.SqlParameter("@MachineName",
Environment.MachineName())

When I run the code in the debugger, I find that the value of
Environment.MachineName is the same as the name of my PC. But I''m
running this on my localhost IIS.

So, my question is: if I run this in my browser but with the
application on a different web server, what will the value of
Environment.MachineName?

Do I make myself clear? Am I as dumb as a bag of spanners?

Edward
--
The reading group''s reading group:
http://www.bookgroup.org.uk



这篇关于可能是关于Environment.MachineName的愚蠢问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆