C#枚舉所有sql server數(shù)據(jù)庫實(shí)例
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
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 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |