MsSQL Database browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lishniy
    New Member
    • Apr 2013
    • 3

    MsSQL Database browser

    How can i browse database name and server to connect?
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    To query the database for other objects you need to connect to it first. Usually one knows the server name and the database name. So you don't know both? So what information do you currently have about the database? If you have nothing then ask the person that installed the database.

    Comment

    • lishniy
      New Member
      • Apr 2013
      • 3

      #3
      i know server name(actually it is localhost), but database create user and name can be various.
      so i have connection line:
      Code:
      SqlConnection connection = new SqlConnection("Data Source=(local)\\DB_name;Initial Catalog="can_be_various";Integrated Security=True");
      I need to browse Initial Catalog of my DB

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Outside .NET you would run the
        Code:
        EXEC sp_databases
        sql.
        In .NET you can use the SQL Server Managed objects see guide here http://msdn.microsoft.com/en-us/library/ms162169.aspx

        Then you can get the server using

        Code:
        server = new Microsoft.SqlServer.Management.Smo.Server("localhost");
        and the databases using
        Code:
        server.Databases

        Comment

        Working...