----- Original Message ----- From: "Leonardo Miliani" <[EMAIL PROTECTED]> To: "mailing list for gambas users" <gambas-user@lists.sourceforge.net> Sent: Friday, September 05, 2008 11:36 PM Subject: Re: [Gambas-user] Maybe a bug in how Gambas manages openDB connections
Benoit Minisini ha scritto: > On vendredi 05 septembre 2008, Leonardo Miliani wrote: >> 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. > > I cannot reproduce the problem with your code. Which version of Gambas do > you > use? > > Note that your code is incorrect anyway: you declare a new connection > object > is a local variable named Connessione in btnCercaTarga_Click which > overrides > the global variable with the same name, and that connection object is not > initialized. > > REgards, > Sorry. I mixed two examples, one with the Connection "Connessione" declared as global and one with the connection declared as local because I was testing the two different ways. But nothing changed for me, I got the same error with both of the cases. Otherwise, the first call to Connessione.Find: Risultato = Connessione.Find("auto", "targa=&1", Trim(txtTarga.Text) works fine; but after I open the second connection, the new attempt to access the first connection give me back that error. -- 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 Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user ------------------------------------------------------------------------- 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 Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user