This article has been dead for over three months
You
Option Explicit
Public dbname() As String ' Array is used elsewhere
Function GetDBNames()
' anything not defined here is defined elsewhere as a global
Dim x As Integer
Dim sql As String
Call opnDB(0) ' External function to Open a MySql connection
sql = "show databases;" ' set sql
rs.Open sql, conn, adOpenStatic, adLockReadOnly ' open the recordset. rs is a global. conn is a global.
x = 1
frmSetup.List1.Clear ' this is a listbox on a form somewhere
Do Until rs.EOF = True ' loop until done
ReDim Preserve dbname(x) ' set a new item in the array
dbname(x) = rs.Fields(0) ' the first (and only) field returned is the db name
If rs.Fields(0) <> "information_schema" Then ' just get the user database names
frmSetup.List1.AddItem (rs.Fields(0)) ' add the db name to the list
end if
rs.MoveNext ' see if there are any more databases
x = x + 1
Loop
Call closdb ' External function to close the recordset and the connection
dbfg = 0 ' global so I know where I came from. Will have various
' values depending on what I'm trying to do.
End Function