Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2007, 01:37 PM
murphys murphys is offline
Senior Member
 
Join Date: Aug 2001
Posts: 2,948
Default how to free the index?

i have the following code

if not Ascending then
begin
cds.IndexFieldNames := '';
ix := TIndexDef.Create(cds.IndexDefs, DBGrid1.Columns[ACol].FieldName, DBGrid1.Columns[ACol].FieldName,[ixDescending]);
cds.IndexName := ix.Name;
end
else
begin
cds.IndexName := '';
cds.IndexFieldNames := DBGrid1.Columns[ACol].FieldName;
end;

it works perfect for both asc and desc
but for desc im creating an index on runtime
how do i make sure the index will be freed
before creating a new one?
notice that a new index might be on another column
please advice

10x
Amos
Reply With Quote
  #2  
Old 04-21-2007, 12:17 PM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: how to free the index?

Just call the DeleteIndex to remove the index

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
  #3  
Old 04-21-2007, 09:19 PM
murphys murphys is offline
Senior Member
 
Join Date: Aug 2001
Posts: 2,948
Default RE: how to free the index?

currently im creating an index
and name it the same as the name of the field
which im indexing

instead u suggest the name will be fixed
and just before creating it, i should deleteindex it?


10x
Amos
Reply With Quote
  #4  
Old 04-21-2007, 10:45 PM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: how to free the index?

Instead of creating a new index definition why you you just add or delete to the single index definition as below

cds.IndexDefs.Add('IndexName','Indexfield',IndexOp tions]);

for removing them if you have only one index at a time then as below:

cds.IndexDefs.Delete(0);

in case you have multiple index then you can delete them based on their names as below:
cds.IndexDefs.Delete(cds.IndexDefs.IndexOf('IndexN ame'));

hope it helps and if it does then you may accept the answere
Reply With Quote
  #5  
Old 04-22-2007, 10:09 AM
murphys murphys is offline
Senior Member
 
Join Date: Aug 2001
Posts: 2,948
Default RE: how to free the index?

.delete(0); did work
but i tried the indexdefs.add u wrote me
and it didnt work for asc mode
it seems to not "refresh" the data once this line is executed
while the code i wrote in my original post, did sort asc and desc accordingly

btw:
is there a way to "refresh" an existing index instead of re-creating it? (re-creating it works, but i wonder if there is a smarter way for that)

10x
Amos
Reply With Quote
  #6  
Old 04-22-2007, 11:24 AM
mshkolnik mshkolnik is offline
Senior Member
 
Join Date: Jul 2001
Posts: 4,195
Default RE: how to free the index?

Yes, use the fixed index name and delete it before create a new

With best regards, Mike Shkolnik
http://www.scalabium.com
Reply With Quote
  #7  
Old 04-22-2007, 11:33 AM
murphys murphys is offline
Senior Member
 
Join Date: Aug 2001
Posts: 2,948
Default RE: how to free the index?

is there a way to "refresh" an existing index instead of re-creating it? (re-creating it works, but i wonder if there is a smarter way for that)

i will accept your answer
but do u know the answer for this one too?

10x
Amos
Reply With Quote
  #8  
Old 04-22-2007, 08:14 PM
digitiger digitiger is offline
Senior Member
 
Join Date: Jan 2001
Posts: 716
Default RE: how to free the index?

No, there is no other way, and I can assure you about that.

you will have to drop the existing index and by calling delete and then add a fresh one
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:59 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.