如何动态获取服务器名称,即在运行时..? [英] How to get server name dynamically i.e in runtime..?
本文介绍了如何动态获取服务器名称,即在运行时..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
hello成员,
如何在我的应用程序安装到计算机上时动态获取服务器名称..
im使用ADO.NET和Sql server 2005 ...? ??
hello members,
how to get server name dynamically when my application gets installed on a machine..
i m using ADO.NET and Sql server 2005...???
推荐答案
试试这个,这可以帮到你
try this, this may helps you
using(SqlConnection _con = new SqlConnection(your-connection-string))
{
string instanceName = new Microsoft.SqlServer.Management.Smo.Server
(new ServerConnection(_con)).InstanceName;
}
谢谢
--RA
Thanks
--RA
这可以帮助你
http://msdn.microsoft.com/en-us/library/system.data.sql.sqldatasourceenumerator.getdatasources.aspx [ ^ ]
这篇关于如何动态获取服务器名称,即在运行时..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文