How to find available SQL Server on local network

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Job Lot

    How to find available SQL Server on local network

    Using VB.NET how can I find all available SQL Server on a local network and
    list all the databases in each server.

    Thanks
  • Jakob Christensen

    #2
    RE: How to find available SQL Server on local network

    You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
    to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
    method which will give you all SQL Servers on the network (if you are running
    Windows 2000 and up).

    You can also connect to an SQL Server instance and enumerate all objects for
    that server (using the SqlServer object).

    Links:



    Of course, the code will be a bit different in VB.net.

    HTH, Jakob.



    "Job Lot" wrote:
    [color=blue]
    > Using VB.NET how can I find all available SQL Server on a local network and
    > list all the databases in each server.
    >
    > Thanks[/color]

    Comment

    • Jakob Christensen

      #3
      RE: How to find available SQL Server on local network

      You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
      to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
      method which will give you all SQL Servers on the network (if you are running
      Windows 2000 and up).

      You can also connect to an SQL Server instance and enumerate all objects for
      that server (using the SqlServer object).

      Links:



      Of course, the code will be a bit different in VB.net.

      HTH, Jakob.



      "Job Lot" wrote:
      [color=blue]
      > Using VB.NET how can I find all available SQL Server on a local network and
      > list all the databases in each server.
      >
      > Thanks[/color]

      Comment

      • Job Lot

        #4
        RE: How to find available SQL Server on local network

        Doesn't it show instances installed on local machine?

        "Jakob Christensen" wrote:
        [color=blue]
        > You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
        > to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
        > method which will give you all SQL Servers on the network (if you are running
        > Windows 2000 and up).
        >
        > You can also connect to an SQL Server instance and enumerate all objects for
        > that server (using the SqlServer object).
        >
        > Links:
        > http://support.microsoft.com/default...b;en-us;287737
        > http://msdn.microsoft.com/library/de...con03_8q44.asp
        >
        > Of course, the code will be a bit different in VB.net.
        >
        > HTH, Jakob.
        >
        >
        >
        > "Job Lot" wrote:
        >[color=green]
        > > Using VB.NET how can I find all available SQL Server on a local network and
        > > list all the databases in each server.
        > >
        > > Thanks[/color][/color]

        Comment

        • Job Lot

          #5
          RE: How to find available SQL Server on local network

          Doesn't it show instances installed on local machine?

          "Jakob Christensen" wrote:
          [color=blue]
          > You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
          > to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
          > method which will give you all SQL Servers on the network (if you are running
          > Windows 2000 and up).
          >
          > You can also connect to an SQL Server instance and enumerate all objects for
          > that server (using the SqlServer object).
          >
          > Links:
          > http://support.microsoft.com/default...b;en-us;287737
          > http://msdn.microsoft.com/library/de...con03_8q44.asp
          >
          > Of course, the code will be a bit different in VB.net.
          >
          > HTH, Jakob.
          >
          >
          >
          > "Job Lot" wrote:
          >[color=green]
          > > Using VB.NET how can I find all available SQL Server on a local network and
          > > list all the databases in each server.
          > >
          > > Thanks[/color][/color]

          Comment

          • Job Lot

            #6
            RE: How to find available SQL Server on local network

            I am getting the following error when i run it on WIN2K

            QueryInterface for interface SQLDMO.NameList failed???

            "Jakob Christensen" wrote:
            [color=blue]
            > You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
            > to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
            > method which will give you all SQL Servers on the network (if you are running
            > Windows 2000 and up).
            >
            > You can also connect to an SQL Server instance and enumerate all objects for
            > that server (using the SqlServer object).
            >
            > Links:
            > http://support.microsoft.com/default...b;en-us;287737
            > http://msdn.microsoft.com/library/de...con03_8q44.asp
            >
            > Of course, the code will be a bit different in VB.net.
            >
            > HTH, Jakob.
            >
            >
            >
            > "Job Lot" wrote:
            >[color=green]
            > > Using VB.NET how can I find all available SQL Server on a local network and
            > > list all the databases in each server.
            > >
            > > Thanks[/color][/color]

            Comment

            • Jakob Christensen

              #7
              RE: How to find available SQL Server on local network

              It seems that this may be a pre-SP2 problem. Did you install all SQL Server
              service packs?

              Regards, Jakob.


              "Job Lot" wrote:
              [color=blue]
              > I am getting the following error when i run it on WIN2K
              >
              > QueryInterface for interface SQLDMO.NameList failed???
              >
              > "Jakob Christensen" wrote:
              >[color=green]
              > > You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
              > > to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
              > > method which will give you all SQL Servers on the network (if you are running
              > > Windows 2000 and up).
              > >
              > > You can also connect to an SQL Server instance and enumerate all objects for
              > > that server (using the SqlServer object).
              > >
              > > Links:
              > > http://support.microsoft.com/default...b;en-us;287737
              > > http://msdn.microsoft.com/library/de...con03_8q44.asp
              > >
              > > Of course, the code will be a bit different in VB.net.
              > >
              > > HTH, Jakob.
              > >
              > >
              > >
              > > "Job Lot" wrote:
              > >[color=darkred]
              > > > Using VB.NET how can I find all available SQL Server on a local network and
              > > > list all the databases in each server.
              > > >
              > > > Thanks[/color][/color][/color]

              Comment

              • Job Lot

                #8
                RE: How to find available SQL Server on local network

                Installing SP3a fixed it. Thanks

                Have another question
                I have installed sql server on stand alone machine, running XP. The code
                doesn't generate error but doesn't even shows the instance of sql server
                installed on it, what could be the problem? Does the method
                ListAvailableSQ LServers() only scans the network for instances of sql server
                and not the local machine?


                "Jakob Christensen" wrote:
                [color=blue]
                > It seems that this may be a pre-SP2 problem. Did you install all SQL Server
                > service packs?
                >
                > Regards, Jakob.
                >
                >
                > "Job Lot" wrote:
                >[color=green]
                > > I am getting the following error when i run it on WIN2K
                > >
                > > QueryInterface for interface SQLDMO.NameList failed???
                > >
                > > "Jakob Christensen" wrote:
                > >[color=darkred]
                > > > You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
                > > > to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
                > > > method which will give you all SQL Servers on the network (if you are running
                > > > Windows 2000 and up).
                > > >
                > > > You can also connect to an SQL Server instance and enumerate all objects for
                > > > that server (using the SqlServer object).
                > > >
                > > > Links:
                > > > http://support.microsoft.com/default...b;en-us;287737
                > > > http://msdn.microsoft.com/library/de...con03_8q44.asp
                > > >
                > > > Of course, the code will be a bit different in VB.net.
                > > >
                > > > HTH, Jakob.
                > > >
                > > >
                > > >
                > > > "Job Lot" wrote:
                > > >
                > > > > Using VB.NET how can I find all available SQL Server on a local network and
                > > > > list all the databases in each server.
                > > > >
                > > > > Thanks[/color][/color][/color]

                Comment

                • Jakob Christensen

                  #9
                  RE: How to find available SQL Server on local network

                  It seems that the NameList returned by ListAvailableSe rvers is 1-based,
                  although it does not fail if you use indices smaller than 1 (it just returns
                  an empty string). So if you use code similar to the following, you will get
                  a server name '(local)' for the local (default) SQL Server instance:

                  SQLDMO.Applicat ion app = new SQLDMO.Applicat ionClass();
                  SQLDMO.NameList names = app.ListAvailab leSQLServers();
                  for (int i = 1; i <= names.Count; ++i)
                  Console.WriteLi ne(names.Item(i ));

                  HTH, Jakob.


                  "Job Lot" wrote:
                  [color=blue]
                  > Installing SP3a fixed it. Thanks
                  >
                  > Have another question
                  > I have installed sql server on stand alone machine, running XP. The code
                  > doesn't generate error but doesn't even shows the instance of sql server
                  > installed on it, what could be the problem? Does the method
                  > ListAvailableSQ LServers() only scans the network for instances of sql server
                  > and not the local machine?
                  >
                  >
                  > "Jakob Christensen" wrote:
                  >[color=green]
                  > > It seems that this may be a pre-SP2 problem. Did you install all SQL Server
                  > > service packs?
                  > >
                  > > Regards, Jakob.
                  > >
                  > >
                  > > "Job Lot" wrote:
                  > >[color=darkred]
                  > > > I am getting the following error when i run it on WIN2K
                  > > >
                  > > > QueryInterface for interface SQLDMO.NameList failed???
                  > > >
                  > > > "Jakob Christensen" wrote:
                  > > >
                  > > > > You can do this using SQL-DMO. Add a reference to sqldmo.dll and sqldmo.rll
                  > > > > to use SQL-DMO. The Application object of SQL-DMO has a ListAvailableSe rvers
                  > > > > method which will give you all SQL Servers on the network (if you are running
                  > > > > Windows 2000 and up).
                  > > > >
                  > > > > You can also connect to an SQL Server instance and enumerate all objects for
                  > > > > that server (using the SqlServer object).
                  > > > >
                  > > > > Links:
                  > > > > http://support.microsoft.com/default...b;en-us;287737
                  > > > > http://msdn.microsoft.com/library/de...con03_8q44.asp
                  > > > >
                  > > > > Of course, the code will be a bit different in VB.net.
                  > > > >
                  > > > > HTH, Jakob.
                  > > > >
                  > > > >
                  > > > >
                  > > > > "Job Lot" wrote:
                  > > > >
                  > > > > > Using VB.NET how can I find all available SQL Server on a local network and
                  > > > > > list all the databases in each server.
                  > > > > >
                  > > > > > Thanks[/color][/color][/color]

                  Comment

                  Working...