ZQuery update

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
lams
Fresh Boarder
Fresh Boarder
Posts: 22
Joined: 13.08.2008, 04:24

ZQuery update

Post by lams »

Hi,

I am using Zeos 6.6.4 with Firebird 2.1

I have a little bit confuse about how to use ZQuery with ZUpdateSQL. I used to put a ZQuery and ZUpdateSQL into the Form, and set ZQuery.UpdateObject to the ZUpdateSQL. Then set the Insert/Update/Modify/Delete/Refresh SQL under ZUpdateSQL component for updating data.

But I just find out ZQuery actually is not a read-only dataset. If my code like this without a ZUpdateQL:

Code: Select all

While not ZQuery.Eof do
begin
  ZQuery.Edit; // Note: no ZUpdateSQL Assign to UpdateObject property
  ZQuery.FieldByName('Title').AsString = 'Test';
  ZQuery.Post;
  ZQuery.Next;
end;
It actually work! So my question is:

Do ZQuery equal to TQuery? Or something special I miss?

Cheers,
Jay
Fresh Boarder
Fresh Boarder
Posts: 20
Joined: 03.03.2006, 03:16
Location: Mexico

Post by Jay »

If you use a TZQuery component and you select from only 1 table, then the dataset is Read/write since the component knows how to do the updates (Insert, update, delete). Example

SELECT * FROM Employees

However, if you select from 2 or more tables, then the component DOES NOT know which table or fields to update. In these cases, you must use the TZUpdateSql component in which YOU specify what table and fields to update and how.

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

Post by mdaems »

Do ZQuery equal to TQuery? Or something special I miss?
They have (about) the same functionality, indeed. They can't be simply swapped, however. A ZQuery always depends on a ZConnection, a TQuery doesn't. When it's about documentation : normally functionality described in Delphi Help about a TQuery should be equal (or very similar) for a ZQuery.

The difference : you don't need the BDE for the zeoslib components. You only need the client dll's for the database of your choice.

Mark
Image
lams
Fresh Boarder
Fresh Boarder
Posts: 22
Joined: 13.08.2008, 04:24

Post by lams »

Thank you for both explanations.

I haven't use TQuery for years and already regard it as a read-only dataset as TIBQuery in the IBX.
Post Reply