Board index » delphi » Record order following a record insert/post

Record order following a record insert/post

Greetings,
I'm assuming that this is not a unique problem.

The Description: I have a data entry form with a datagrid and some dbedit
fields. The dbedit fields are bound to the master table and the dbgrid is
bound to the detail table. The tables are using two ado table components and
one shared connection component. I am using MS SQL 2000 for the database.
Both tables have a CursorLocation of "clUseClient" and a CursorType of
"ctStatic". Also each table has the 'indexName' set to its primary index.

The problem/Issue: when i start the application, everything appears to be
just fine. As I page through the master table, it cycles in the appropriate
order, by primary key; as does the detail table. However, once i insert a
new record, in either the master or detail, the new record moves to the end
of the table, regardless of its 'true' logical' location within the table.
Now, if I refresh (programmatically close and reopen the tables) the new
records then move to their correct place within the displayed tables.

Why is this so, and is there a fix?

I did attempt to play with the CursorLocation and CursorType properties, but
the response time was horrible that once the program finally load, i
immediately shut it down.

Thanks in advance,

Ron Malizia
RMali...@co.grays-harbor.wa.us

 

Re:Record order following a record insert/post


Since you are using  a client cursor , no index is updated when you add the
record. The index is maintained on the server not the client result set.
When you use tables in ADO, the whole table is read in before anything
happens which can be a real show-stopper if the table is much bigger than a
hundred records or so. You have to post and re-read the records in order for
the table to be reordered to "logica index" order. This aint dBase ya know
:)

Re:Record order following a record insert/post


Quote
>The problem/Issue: when i start the application, everything appears to be
>just fine. As I page through the master table, it cycles in the appropriate
>order, by primary key; as does the detail table. However, once i insert a
>new record, in either the master or detail, the new record moves to the end
>of the table, regardless of its 'true' logical' location within the table.
>Now, if I refresh (programmatically close and reopen the tables) the new
>records then move to their correct place within the displayed tables.

>Why is this so, and is there a fix?

Your dataset is in memory with no instructions on how to order its rows.
Use the IndexFieldNames property to fix this.  Note that if you are using a
detail table indexFieldnames must first include any fields you are liking on.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads