CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    Available Databases?

    Hi,
    Does anyone know how to give a user a selection of available databases in SQL SERVER 6.5 using VB
    ie
    When they log in the can choose between different databases.
    This is when I'm using OLEDB as I know that with ODBC I can just change the default database in the control panels but I can't see a way of doing this sort of thing with OLEDB where you hard code the INITIAL CATALOG and I don't want to use an INI file to select the database I'm working with.
    Hope this makes sense
    Cheers.



  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Available Databases?

    Here is some code that I use to do this:

    Dim RS as Recordset
    Dim sSQL as string

    sSQL = "SELECT Name FROM Master..SysDatabases (nolock)"

    set RS = Conn.Execute(sSQL)

    cboDB.Clear

    Do While Not RS.EOF
    cboDB.AddItem RS!Name
    RS.MoveNext
    Loop




    The master database is a wonderful thing. But the master database is sort of like the registry on your PC - it holds info about everything, so if one thing gets messed up, the whole DB could blow up.

    Hope this helps,
    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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

Featured