Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Enumerate SQL data sources

Enumerate SQL data sources

Scheduled Pinned Locked Moved Database
questioncsharpdatabase
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RFickling
    wrote on last edited by
    #1

    Hi, How can I enumerate SQL data sources in my domain using C#? I found MS KnowledgeBase article 310107, but I can't get the code to even compile. Thanks, Royce

    G J 2 Replies Last reply
    0
    • R RFickling

      Hi, How can I enumerate SQL data sources in my domain using C#? I found MS KnowledgeBase article 310107, but I can't get the code to even compile. Thanks, Royce

      G Offline
      G Offline
      gnjunge
      wrote on last edited by
      #2

      Well this is more simple than you think. It's merely a SQL Query that you need to use: select name from master..sysdatabases Will select all the data sources from the current SQL instance. So create a SQL command, and use this as the query, and your result will be a table with datasources. Hope this helps. Gidon

      R 1 Reply Last reply
      0
      • G gnjunge

        Well this is more simple than you think. It's merely a SQL Query that you need to use: select name from master..sysdatabases Will select all the data sources from the current SQL instance. So create a SQL command, and use this as the query, and your result will be a table with datasources. Hope this helps. Gidon

        R Offline
        R Offline
        RFickling
        wrote on last edited by
        #3

        Gidon, Thanks for your help. I am a newbie to SQL (as you might have guessed), so maybe I misstated my problem. I am equating "data source" to "server", as described in the help for the SqlConnection class: Data Source -or- Server -or- Address: The name or network address of the instance of SQL Server to which to connect. So I want to find all of the servers on the current domain. Royce

        G L 2 Replies Last reply
        0
        • R RFickling

          Gidon, Thanks for your help. I am a newbie to SQL (as you might have guessed), so maybe I misstated my problem. I am equating "data source" to "server", as described in the help for the SqlConnection class: Data Source -or- Server -or- Address: The name or network address of the instance of SQL Server to which to connect. So I want to find all of the servers on the current domain. Royce

          G Offline
          G Offline
          gnjunge
          wrote on last edited by
          #4

          Well the truth I'm not sure. You can maybe loop through all the computers in the domain, and try to make a sqlconnection, if it succeeds you know there is a SQL server on that computer in the domain. I did a quick google search and found this thread about listing computers in the domain using .NET http://www.dotnet247.com/247reference/msgs/32/161278.aspx[^] Gidon

          1 Reply Last reply
          0
          • R RFickling

            Gidon, Thanks for your help. I am a newbie to SQL (as you might have guessed), so maybe I misstated my problem. I am equating "data source" to "server", as described in the help for the SqlConnection class: Data Source -or- Server -or- Address: The name or network address of the instance of SQL Server to which to connect. So I want to find all of the servers on the current domain. Royce

            L Offline
            L Offline
            Luis Alonso Ramos
            wrote on last edited by
            #5

            See this article: http://www.codeproject.com/cs/database/LocatingSql.asp[^] -- LuisR


            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

            1 Reply Last reply
            0
            • R RFickling

              Hi, How can I enumerate SQL data sources in my domain using C#? I found MS KnowledgeBase article 310107, but I can't get the code to even compile. Thanks, Royce

              J Offline
              J Offline
              jonathan15
              wrote on last edited by
              #6

              Using SQLDMO is by far the easiest way to do this. It is a pain to distribute though because you need to distribute half a dozen com dlls and some of them need to go into specific folders. I did one of these recently and it took me nearly a day to find the documentation on distributing DMO correctly. Jon

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups