C#枚舉所有sql server數據庫實例
當前位置:點晴教程→知識管理交流
→『 技術文檔交流 』
DataTable dataSources = SqlClientFactory.Instance.CreateDataSourceEnumerator().GetDataSources(); DataColumn column2 = dataSources.Columns[ "ServerName" ]; DataColumn column = dataSources.Columns[ "InstanceName" ]; DataRowCollection rows = dataSources.Rows; string [] array = new string [rows.Count]; for ( int i = 0; i < array.Length; i++) { string str2 = rows[i][column2] as string ; string str = rows[i][column] as string ; if (((str == null ) || (str.Length == 0)) || ( "MSSQLSERVER" == str)) { array[i] = str2; } else { array[i] = str2 + @"\" + str; } } Array.Sort< string >(array); 該文章在 2021/4/23 17:36:57 編輯過 |
關鍵字查詢
相關文章
正在查詢... |