Click to See Complete Forum and Search --> : Available Databases?


February 8th, 2000, 10:54 AM
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.

Johnny101
February 8th, 2000, 12:13 PM
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