* * *

Author Topic: Trying to enter a TBufDataset.IndexName and it keeps disappearing.  (Read 434 times)

RedOctober

  • Jr. Member
  • **
  • Posts: 60
I have nothing in the .IndexFieldName property, it's empty.  I have configured a index called cdsUsrIdxLoginID which has a Fields property of LoginID and is ixPrimary.  When I go to the TBufDataSet and try to set the IndexName property, the name I paste into the property disappears and the phrase   'DEFAULT_ORDER' appears instead.

I am sure the field name I used for the IndexDef is correct.  My MaxIndexes is 2 (the default)

What am I missing?  Thanks in advance for any help you can provide.

RedOctober

  • Jr. Member
  • **
  • Posts: 60
Re: Trying to enter a TBufDataset.IndexName and it keeps disappearing.
« Reply #1 on: January 04, 2018, 07:40:55 pm »
I have made a small sample project showing the problem.  Maybe I am missing something.

GetMem

  • Hero Member
  • *****
  • Posts: 2619
Re: Trying to enter a TBufDataset.IndexName and it keeps disappearing.
« Reply #2 on: January 06, 2018, 10:10:30 am »
Hi RedOctober,

Clear  IndexDef, IndexFieldName, IndexName then:
Code: Pascal  [Select]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   BufDataset1.MaxIndexesCount := 2;
  4.   BufDataset1.AddIndex('LoginIndex', 'LoginID', [ixPrimary, ixUnique]);
  5.   BufDataset1.IndexFieldNames:='LoginID';
  6.   BufDataset1.IndexName := 'LoginIndex';
  7.   BufDataset1.CreateDataSet;
  8. end;

PS: Test project attached.

RedOctober

  • Jr. Member
  • **
  • Posts: 60
Re: Trying to enter a TBufDataset.IndexName and it keeps disappearing.
« Reply #3 on: January 06, 2018, 06:47:23 pm »
Thank you GetMem.  After some experimentation, I was able to determine that I can set all the index related properties (including defs) at design time.  The only property that cannot be set (which is a bug in Laz 1.9 or Fbc 3.1.1) is the IndexName.

So, in my project code, I simply set the IndexName in code, BEFORE I do a .CreateDataset;

This was the most important clue you gave me, and it solved my problem.  Thank you.

Example:
.. set all other settings in the Lazarus IDE, then hardcode:

Code: Pascal  [Select]
  1.   BufDataset1.IndexName := 'LoginIndex';
  2.   BufDataset1.CreateDataSet;
  3.  




 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus