I need to get the local computer name and add it to a box but when I run this code I get the server name. How can I get the local computer name instead?
SNosko
_________________
Imports System
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.management
Imports System.Web
Imports System.Net
Imports System.Environment
________________
Public Sub New()
objOS = New ManagementObjectSearcher("Select * From Win32_OperatingSystem")
For Each objMgmt In objOS.Get
m_strComputerName = objMgmt("csname").ToString()
Next
End Sub
Public ReadOnly Property ComputerName()
Get
ComputerName = m_strComputerName
End Get
End Property
_______________
Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
varComNM = ComputerName()
Me.txtComNM.Text = varComNM
End Sub
SNosko
_________________
Imports System
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.management
Imports System.Web
Imports System.Net
Imports System.Environment
________________
Public Sub New()
objOS = New ManagementObjectSearcher("Select * From Win32_OperatingSystem")
For Each objMgmt In objOS.Get
m_strComputerName = objMgmt("csname").ToString()
Next
End Sub
Public ReadOnly Property ComputerName()
Get
ComputerName = m_strComputerName
End Get
End Property
_______________
Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
varComNM = ComputerName()
Me.txtComNM.Text = varComNM
End Sub