Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004

    Unanswered: displaying list of available databases in SQL Server 2000 using VB??

    I am creating a userform to compare tables in different databases. How do i go about populating a listbox with all the database names associated with my SQL Server 2000 instance? I would rather populate a list than creating text boxes to select of the databases i know will exist, users will also create new databases so that approach would be flawed.

    So anyone know how i can do this using VB? I just want to know how to access the database names since usually you need the database name to connect to SQL Server to begin with

  2. #2
    Join Date
    Mar 2004
    To get a list of databases on a server execute the following:

    SELECT * FROM master..sysdatabases
    To leave out the standard system databases:

    SELECT * FROM master..sysdatabases WHERE name NOT IN ('tempbd', 'master', 'model', 'msdb')

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

Posting Permissions

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