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 编辑过 |
关键字查询
相关文章
正在查询... |