private void Form2_Load(object sender, EventArgs e) { listBox1.Items.Clear(); SQLDMO.Application SQLServer = new SQLDMO.Application(); SQLDMO.NameList strServer = SQLServer.ListAvailableSQLServers(); if (strServer.Count > 0) { for (int i = 0; i < strServer.Count; i++) { listBox1.Items.Add(strServer.Item(i + 1)); } } }
原文:http://blog.csdn.net/lucky51222/article/details/40582963