BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sorting with IndexName property

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier)
View previous topic :: View next topic  
Author Message
Fernando
Guest





PostPosted: Tue Aug 26, 2003 7:19 pm    Post subject: Sorting with IndexName property Reply with quote




I'm having some problems trying to apply a new sort field in a
existing IndexDef.

I have a IndexName called idxMySort sorting the dataset (TClientDataSet)
by 'Code' (idxMySort.Fields = 'Code') and I want to change the
sort order to 'Name', putting in the Fields property the
value 'Name' (idxMySort.Fields = 'Name'). The new sort order is
only applyed after I close and reopen the DataSet. I need to
know the best way to do it, without using close and open (wich
is too slow).

I have posted this question in ADO newsgroup and I've got no answer...

Thank's in advance.
Fernando


Back to top
Bill Todd
Guest





PostPosted: Tue Aug 26, 2003 9:59 pm    Post subject: Re: Sorting with IndexName property Reply with quote



I am having some trouble understanding your message. If you have two
indexes, one named CodeIndex and one named NameIndex all you have to
do is:

ClientDataSet1.IndexName := 'CodeIndex';
ClientDataSet1.IndexName := 'NameIndex';


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Back to top
Fernando
Guest





PostPosted: Tue Aug 26, 2003 10:27 pm    Post subject: Re: Sorting with IndexName property Reply with quote




I have only one index, named 'GenericIndex'. The initial state
of this index is sort by 'Code' field (setting the Fields
property to 'Code'). Now I want to sort the DataSet by 'Name'
using the same index ('GenericIndex'), setting the Fields
property to 'Name' (the old Fields property value, that
was 'Code', now is changed to 'Name'). But the new sort is not
applyed until I close and reopen the DataSet.

// initial state of index is sorted by 'Code'
GenericIndex.Fields := 'Code';

// the DataSet is indexed by 'GenericField' and ordered
// by 'Code'
DataSet.IndexName := 'GenericIndex';

// now I change the Fields property to 'Name' to sort
// by 'Name', but the dataset donīt change the order.
GenericIndex.Fields := 'Name';

I need refresh the sort order of dataset when I change the
Fields property to new FieldName, without changing the
IndexName property of DataSet to other index. Is there any way
to do it?

Thank you very much...

P.S. Sorry about my english, I'm Brazilian....
Back to top
Bill Todd
Guest





PostPosted: Wed Aug 27, 2003 12:59 am    Post subject: Re: Sorting with IndexName property Reply with quote

Then why use an index at all. Just assign the field name to the
IndexFieldNames property.

If you do decide to use indexes you must use two indexes to be able to
change them quickly at runtime.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Back to top
Fernando
Guest





PostPosted: Wed Aug 27, 2003 10:54 am    Post subject: Re: Sorting with IndexName property Reply with quote


IndexFieldNames donīt accept descending sort order... :(

Creating dinamically indexes at run time affect the performance of dataset?

Thanks...
Fernando

Bill Todd <no (AT) no (DOT) com> wrote:
Quote:
Then why use an index at all. Just assign the field name to the
IndexFieldNames property.

If you do decide to use indexes you must use two indexes to be able to
change them quickly at runtime.


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)



Back to top
Bill Todd
Guest





PostPosted: Wed Aug 27, 2003 3:01 pm    Post subject: Re: Sorting with IndexName property Reply with quote



On 27 Aug 2003 03:54:45 -0700, "Fernando" <fernando (AT) headsoft (DOT) com.br>
wrote:

Quote:
Creating dinamically indexes at run time affect the performance of dataset?

Not if the number of records is a few thousand or less.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (Multi-Tier) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.