I would like to get your attention on what I think is a bug of how
Gambas manages open DB connections.

In a project of mine, I manage 2 connections to a MySQL DB.
In a form of that project I open the first connection and get a result
with the Connection.Find() method; then, I open the second connection.
After this, if I try to make another operation on the first connection I
get an "Invalid object" error.
It seems that Gambas, when it opens the second connection, deletes all
the old ones so it has no more references to other connections but the
last one.

Example code:
PRIVATE Connessione AS NEW Connection
PRIVATE Risultato AS Result

PUBLIC SUB Form_Open()
  WITH Connessione
    .Name = MySQL.NomeDB
    .Type = "mysql"
    .User = MySQL.Utente
    .Password = MySQL.Password
    .Host = MySQL.Host
    .Open
  END WITH
END

PUBLIC SUB btnCercaTarga_Click()
DIM Connessione AS NEW Connection
DIM Connessione2 AS NEW Connection
DIM Risultato AS Result
DIM Risultato2 AS Result

  Risultato = Connessione.Find("auto", "targa=&1", Trim(txtTarga.Text))
  IF Risultato.Available = FALSE THEN
    RETURN
  END IF

  WITH Connessione2
    .Name = MySQL.NomeDB
    .Type = "mysql"
    .User = MySQL.Utente
    .Password = MySQL.Password
    .Host = MySQL.Host
    .Open
  END WITH

  Risultato.MoveFirst  **  <---------------  Here I get the error **
[...]


To solve this, I had to call the Connection.Find() method another time
before to access to the Result class.

-- 
Ciao.
Leo.

Web: www.leonardomiliani.com
E-mail: [EMAIL PROTECTED]
Scegli software opensource - Choose opensource software

Co-fondatore di Gambas-it.org
Il sito di riferimento della comunità italiana degli utenti di Gambas
www.gambas-it.org

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to