Create an index for a TClientDataSet at runtime

简介: I had originally created the index with the property IndexName and finally found out that this did not select my index.

I had originally created the index with the property IndexName
and finally found out that this did not select my index.
Selecting the index by the property IndexFieldNames worked fine,
as the following source shows.

This is also an example how to create a memory table.. 
   
  with CDS1 Do
  begin
    Close;
    // Define the fields
    FieldDefs.Clear;
    FieldDefs.Add ('Project', ftInteger, 0, True);
    FieldDefs.Add ('Module',  ftString, 60, False);
    FieldDefs.Add ('FuncName',ftString, 60, False);
    FieldDefs.Add ('FuncDate',ftDate,    0, False);
    FieldDefs.Add ('FuncCRC', ftString,  2, False);
    FieldDefs.Add ('Programmer', ftString, 32, False);
    // Define the index
    IndexDefs.Clear;
    IndexDefs.Add ('IProject', 'Project;Module;FuncName',
                   [ixPrimary, ixUnique]);
    // this seems not to do anything
    IndexName := 'IProject';

    // this does work
    IndexFieldNames := 'Project;Module;FuncName';

    // Create the dataset
    CreateDataSet;
    Open;
  end;

目录
相关文章
|
6月前
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘thinkphp.test‘ don‘t exsit
111 0
|
10月前
|
PHP
thinkphp报错Call to undefined method app\index\controller\Index::fetch()
thinkphp报错Call to undefined method app\index\controller\Index::fetch()
99 0
|
11月前
|
存储 算法 API
|
测试技术 PHP
PHP:laravel自定义Model报错:$table must not be defined/$table must be string
PHP:laravel自定义Model报错:$table must not be defined/$table must be string
103 0
|
Java 开发工具
gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.crea
gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
6661 0
How to add extension field to report
How to add extension field to report
107 0
custom field further usage - add into UI and report
custom field further usage - add into UI and report
114 0
custom field further usage - add into UI and report
Cluster table import - BSP UI component source code is actually stored in cluster table
Cluster table import - BSP UI component source code is actually stored in cluster table
Cluster table import - BSP UI component source code is actually stored in cluster table
new Grammar in 740 - Internal table group by
Created by Wang, Jerry, last modified on Sep 14, 2015
new Grammar in 740 - Internal table group by
demo4 debug - create class instance - component works as type
Created by Wang, Jerry, last modified on Feb 23, 2016
94 0
demo4 debug - create class instance - component works as type