I suggest the following code.

    PRIVATE $hConn AS Connection

    PUBLIC SUB GoConnect()
      DIM sName AS String
      TRY $hConn.Close
        sName = "fgda"
        WITH $hConn
          .Type = "mysql"
          .Host = "localhost"
          .Login = "yourusername"
          .Password = "yourpassword"
        END WITH
        $hConn.Name = sName
        $hConn.Open
      CATCH
        Message.Error(Error.Text)
    END

    PUBLIC SUB Form_Open()
      $hConn = NEW Connection
      GoConnect
      label1.Text ="Ok."
    END

    PUBLIC SUB Form_Close()
      $hConn.Close
    END

AndyBertini