How can I get all the SQL Server names in the current lan?

Source: Internet
Author: User
Writing a winform in the past few days
Queries data on any SQL server in the LAN.
Some problems occurred when calling the COM component sqldmo, which have not been solved
Partial tests Code Using System;
Using System. net. Sockets;
Using System. net;
Using System. text;
Using System. Threading;
Using Sqldmo;
Namespace Leleapplication2
{
///   <Summary>
/// Class1.
///   </Summary>
Class Class1
{
///   <Summary>
/// ApplicationProgram.
///   </Summary>

[Stathread]
Static   Void Main ( String [] ARGs)
{
//
// Todo: Add code here to start the application
//
Sqldmo. namelist ns;
Sqldmo. applicationclass rs = New Sqldmo. applicationclass ();
Try  
{
NS = Rs. listavailablesqlservers ();
For ( Int I = 0 ; I < NS. Count; I ++ )
{
Console. writeline (NS. Item (I ));
}
}
Catch (exception ex)
{< br> console. writeline (ex. tostring ());
}< P>

}< BR >}< br>

operation failed:
the interface sqldmo is displayed. queryInterface of namelist failed

have you ever written similar programs? Which of the above has a problem? The error line during debugging is

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.