欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET獲取MS SQL Server安裝實(shí)例實(shí)現(xiàn)思路及代碼

 更新時(shí)間:2013年01月29日 11:11:04   作者:  
在演示中,是把找到的實(shí)例顯示于DropDownList控件中。首先在.aspx拉一個(gè)DropDownList控件,感興趣的朋友可以了解下哦,或許對(duì)你有所幫助
參考MSDN的文章 http://msdn.microsoft.com/zh-cn/library/a6t1z9x2.aspx中所指的SqlDataSourceEnumerator類別,是應(yīng)用程序在當(dāng)前的網(wǎng)絡(luò)中查找SQL Server實(shí)例。
Insus.NET在演示中,是把找到的實(shí)例顯示于DropDownList控件中。首先在.aspx拉一個(gè)DropDownList控件:
復(fù)制代碼 代碼如下:

Server: <asp:DropDownList ID="DropDownListInstance" runat="server"></asp:DropDownList>

然后在Page_Load事件寫:
復(fù)制代碼 代碼如下:

View Code
protected void Page_Load(object sender, EventArgs e)
{
DataTable dataTable = SqlDataSourceEnumerator.Instance.GetDataSources();
foreach (DataRow dr in dataTable.Rows)
{
if (string.IsNullOrEmpty(dr["InstanceName"].ToString()))
this.DropDownListInstance.Items.Add(string.Concat(dr["ServerName"]));
else
this.DropDownListInstance.Items.Add(string.Concat(dr["ServerName"], "\\", dr["InstanceName"]));
}
}

運(yùn)行結(jié)果,Insus.NET的手提電腦安裝了SQL Server 2012和SQL Server 2008 R2,因此顯示兩個(gè)SQL Server實(shí)例。

相關(guān)文章

最新評(píng)論