Page 1 of 1

Firebird gets disconnect after a query

Posted: 17.05.2009, 20:02
by rgkx
hi guys ,

I´am using lazarus 0.9.26.2 and the latest Zeos DB from svn and Firebird 2.1 .

I´ve made a little app to test it and all works fine until
I add or delete a record ,NOT using the TDBNavigator then
the app disconnect from the database ....


The code that I use using a BitBtn is :

procedure TForm1.BitBtn1Click(Sender: TObject);
begin

with zquery1 do begin
Close;
SQL.Clear;
SQL.Add('INSERT INTO zona (id_zona, zona_descrip , comentarios_zona ) VALUES(');
SQL.Add('''' + edit1.Text + ''',''' + edit2.text + ''',''' + memo1.text + ''')');
ExecSQL;
Close;

end ;
end;


I've tested tht zeos component with a Mysql and the results are the same :

What Can I add to keep the connection to the database ?

Is it a bug in ZeosDB ?

when I use the TDBNavigator all works fine .


Thanks in advance ,

Regards

Rick

Posted: 17.05.2009, 22:15
by seawolf
Hi, it would interesting to know how you understand coneection is down.
I mean after that insert or delete Do you do a query?
Or you have a DBGrid linked to a query where data disappear?

Posted: 18.05.2009, 21:10
by rgkx
hi ,

I gets disconnect when I add or delete a record , the dbgrid turn deactivated and the DBNavigator too .

what would be the problem ?

Thanks ,
regards

Posted: 18.05.2009, 22:13
by seawolf
DBGrid shows the same table you want to add or delete rows?

Posted: 19.05.2009, 20:26
by rgkx
hi ,

I resolved the problem :

The zquery gets disconnect after any query .
So I reconnect it .

Thanks ,
Regards

Posted: 19.05.2009, 21:13
by mdaems
Hi Rick,

This isn't a solution at all! It's a dirty workaround.
But I still wonder how it's possible the connection is closed?

:idea: Wait, it may be a stupid question, but is the zquery1 in your code the one that was displaying the data in the grid or is there a second query that's linked to the datagrid? In case you're only using one query component : you're doing it all wrong (sorry, but that's the truth).

So I propose 2 solutions:
- If you don't want to change the data shown in the grid but only the data in the database you could write your own sql statement and execute it using ZConnection.ExecuteDirect. (Eventually after that action you can refresh the dataset using ZQuery.Refresh, but that eats resources)
- If you want to edit the data in the grid itself programmatically you should set the dataset values using Append...set field values...Post. This is the recommended way of working. When the query is easy enough to be updatable using TDBNavigator, there shouldn't be any problem.

Mark