Problems with DBGrid

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
carlocat
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 16.04.2010, 15:28

Problems with DBGrid

Post by carlocat »

Hello,
i've got this situation:

- Delphi 2010
- TZquery (every version, even the ZEOSLIB_TESTING_REV800_COMPACT version)
- TDBGrid linked to the datasource of the TZquery

At the beginning i've got these DataSet:

recno field1 field2 field3

1 R R R
2 G G G
3 H H H
4 P P P

And the cursor positionated at recno n° 2.

Then i make a simple update operation:

table.Edit;
table.FieldByName('FIELD2').AsString := 'X';
table.Post;

After post i've got this result:

recno field1 field2 field3

1 R R R
2 P P P
3 H H H
4 G X G

And the cursor positionating at recno n° 4!

Is this a problem of bookmark??

Thank you in advance
Carlo
carlocat
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 16.04.2010, 15:28

Post by carlocat »

Anyone can help me please?
guidoaerts
Senior Boarder
Senior Boarder
Posts: 93
Joined: 01.07.2009, 16:07

Post by guidoaerts »

Carlocat,
Do you have an index or filter active?
What is the code for positioning the cursor?

Guido
Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 164
Joined: 18.03.2008, 13:03
Contact:

Post by Wild_Pointer »

carlocat,

you haven't noted what DB you are using.
I guess that you don't have the order by statement in your query. Because of that when you post the changes, the record goes to the end of your result set.
When testing on postgresql I get similar results but the order changes not immediately after POST, but after REFRESH.
So please try using sorting or ORDER BY and see if the behavior changes.
carlocat
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 16.04.2010, 15:28

Post by carlocat »

Hello to everyone,
sorry i've forgotten the DB. I'm using PostgresSQL. I don't have filter and order by. The ZQuery using a sortorder to field1. Removing the field it works. So my question is:"Why the dataset change if i change the field2 that is not sorted"?

Thank you in advance,
Carlo

p.s. sorry for my bad english!
Wild_Pointer
Expert Boarder
Expert Boarder
Posts: 164
Joined: 18.03.2008, 13:03
Contact:

Post by Wild_Pointer »

carlocat,
Removing the field it works.
do you mean that then you remove field1 from TZQuery.SortedFields the record jumping stops ?

Have tried using zeos not form testing branch ?
Anyway I've tried editing fields and didn't observe the behavior you did.
Would you please provide a simple test case? SQL to create a table and the source of a small program that illustrates the behavior would be enough.
guidoaerts
Senior Boarder
Senior Boarder
Posts: 93
Joined: 01.07.2009, 16:07

Post by guidoaerts »

after all, after the editing the records are sorted on field1, but in descending order (r,p,h,g).... before the editing, the records are not sorted on field1 (r,g,h,p)
isn't that what is should do?
guido
carlocat
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 16.04.2010, 15:28

Post by carlocat »

Sorry for the delay, i was out from my office for a project.
First of all thank you very much for the answers: I give you a simple project to replicate the problem:

This is the table:

CREATE TABLE test
(
recno serial NOT NULL,
field1 character(10),
field2 character(10),
field3 character(10),
codext integer,
data timestamp without time zone,
CONSTRAINT test_pkey PRIMARY KEY (recno)
)
WITH (OIDS=FALSE);
ALTER TABLE test OWNER TO admin;

And in the attachment you will find the example project.

Of course you need to check the properties of ZConnection...

Thank you again in advance.
Carlo
You do not have the required permissions to view the files attached to this post.
trupka
Expert Boarder
Expert Boarder
Posts: 140
Joined: 26.08.2007, 22:10

Post by trupka »

carlocat,

i did some tests with your example and can confirm same problem in Delphi2007 (so, it's not D2009/10) issue. Problem disappears when ZQuery1.Options[doDontSortOnPost] := false so I think this bug is not directly related to Bookmars.
Can someone else confirm this?
carlocat
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 16.04.2010, 15:28

Post by carlocat »

So, do you confirm that there is a bug?

Thank you very much.
Carlo
Locked