title: MySQL Check if a database exists
body: <p>I'm trying to determine if a database of a certain name exists and then create it if it does not. Ideally this would be in VBScript. I currently am trying using a loop search of an array but the total number of databases will change greatly.</p>
  
  <pre><code>set dbQuery = ConnSQL.execute(checkDBsql) 
              if dbQuery.BOF and dbQuery.EOF then ' Query didn't return any records.
                  ConnSQL.execute(MakeDb)
              else
                  dbQuery.MoveFirst
                  i = 0
                  Do While Not dbQuery.EOF
                      i = i + 1
                  loop
              end if
      set dbQuery = ConnSQL.execute(checkDBsql)
              if dbQuery.BOF and dbQuery.EOF then ' Query didn't return any records.
                  msgBox "ERROR!"
              else
                  e = 0
                  do while not dbQuery.EOF
                      DBName(e) = dbQuery("Database")
                      e = e + 1
                  loop                
                  For a = 1 to UBound(DBName)
                      If DBName(a) = OldDBName Then
                          MsgBox DBName(a)
                      end if
                  Next
      connSQL.close
  </code></pre>