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
Firebird gets disconnect after a query
Moderators: gto, cipto_kh, EgonHugeist
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
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?
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
This isn't a solution at all! It's a dirty workaround.
But I still wonder how it's possible the connection is closed?
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