Firebird gets disconnect after a query

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
rgkx
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 06.05.2009, 23:51

Firebird gets disconnect after a query

Post 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
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post 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?
rgkx
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 06.05.2009, 23:51

Post 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
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

DBGrid shows the same table you want to add or delete rows?
rgkx
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 06.05.2009, 23:51

Post by rgkx »

hi ,

I resolved the problem :

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

Thanks ,
Regards
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply