Results 1 to 3 of 3

Thread: [RESOLVED] Getting Database names

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    fgh
    Posts
    332

    Resolved [RESOLVED] Getting Database names

    I have a listbox control and need to extract all the databases in the local MSSQl server to listbox control (using sqlconnection)

    Code please...
    Last edited by Hack; Sep 27th, 2007 at 07:53 AM. Reason: Added RESOLVED to thread title and green resolved checkmark
    gh

  2. #2
    New Member
    Join Date
    Sep 2007
    Posts
    4

    Re: Getting Database names

    using SQLDMO; (By adding reference to SQLDMO.dll)

    SQLDMO.SQLServerClass objSQLServer = new SQLDMO.SQLServerClass();
    objSQLServer.Connect("server", "username", "password");
    foreach ( SQLDMO.Database db in objSQLServer.Databases)
    {
    ListBox2.Items.Add(db.Name);
    }
    Last edited by ksureshreddy27; Sep 27th, 2007 at 06:32 AM.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2002
    Location
    fgh
    Posts
    332

    Re: Getting Database names

    Quote Originally Posted by ksureshreddy27
    using SQLDMO; (By adding reference to SQLDMO.dll)

    SQLDMO.SQLServerClass objSQLServer = new SQLDMO.SQLServerClass();
    objSQLServer.Connect("server", "username", "password");
    foreach ( SQLDMO.Database db in objSQLServer.Databases)
    {
    ListBox2.Items.Add(db.Name);
    }

    thanks yar!!!
    gh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width