在C#上工作,在我的一个应用程序中,我需要获取SQL Server名称。在网络中,我有SQL Server 2000,2005,2008。对于我的应用程序,我想获取服务器名称。如何获得没有连接字符串的SQL Server名称
private string strConnection = @"Data Source=xxx;Initial Catalog=xxx;Integrated Security=True";
SqlConnection objConnection = new SqlConnection(strConnection);
objConnection.Open();
SqlCommand objCommand = new SqlCommand(“xxxxxxx”);
objCommand.ExecuteNonQuery();
objConnection.Close();
如果我知道strConnection
那么我可以使用上面的语法。但我不知道服务器名称。首先,我需要知道服务器名称。我需要帮助来获取服务器名称。
+1 ADO.NET实用程序类非常好。我正在考虑nmaping,而不是。 :) – Icarus