[Gambas-user] Maybe a bug in how Gambas manages open DB connections

Leonardo Miliani leonardo at ...1237...
Fri Sep 5 12:33:57 CEST 2008


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: leonardo at ...1237...
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




More information about the User mailing list