using System.Net; string getHost = System.Net.Dns.GetHostName(); string getIP = System.Net.Dns.GetHostByName(getHost).AddressList[0].ToString();
Monday, March 28, 2011
To get the Host Name and IP address in C#
To Findout the Port no. , Server name of sql server.
DECLARE @SqlServerName VARCHAR(255)
, @SqlVersion VARCHAR(255)
, @PortNumber VARCHAR(10)
DECLARE @Result TABLE(ServerName VARCHAR(255), Version VARCHAR(255), Port VARCHAR(10))
SELECT @SqlServerName = @@ServerName, @SqlVersion = LEFT(@@Version, 38)
EXEC xp_regread
@rootkey = 'HKEY_LOCAL_MACHINE',
@key = 'SOFTWARE\MICROSOFT\MSSQLSERVER\MSSQLSERVER\SUPERSOCKETNETLIB\TCP',
@value_name = 'TcpPort',
@value = @PortNumber output
Select @PortNumber,@SqlServerName ,@SqlVersion
, @SqlVersion VARCHAR(255)
, @PortNumber VARCHAR(10)
DECLARE @Result TABLE(ServerName VARCHAR(255), Version VARCHAR(255), Port VARCHAR(10))
SELECT @SqlServerName = @@ServerName, @SqlVersion = LEFT(@@Version, 38)
EXEC xp_regread
@rootkey = 'HKEY_LOCAL_MACHINE',
@key = 'SOFTWARE\MICROSOFT\MSSQLSERVER\MSSQLSERVER\SUPERSOCKETNETLIB\TCP',
@value_name = 'TcpPort',
@value = @PortNumber output
Select @PortNumber,@SqlServerName ,@SqlVersion
Subscribe to:
Posts (Atom)