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;

目录
相关文章
|
5月前
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
90 0
|
9月前
|
PHP
thinkphp报错Call to undefined method app\index\controller\Index::fetch()
thinkphp报错Call to undefined method app\index\controller\Index::fetch()
88 0
|
10月前
|
存储 算法 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
102 0
|
Java 开发工具
gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.crea
gradle Could not create service of type CrossBuildFileHashCache using BuildSessionScopeServices.createCrossBuildFileHashCache().
6645 0
How to add extension field to report
How to add extension field to report
106 0
|
人工智能 安全 Java
create PDF in console with no environment variable set
create PDF in console with no environment variable set
106 0
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
new Grammar in 740 - internal table filter
Created by Wang, Jerry, last modified on Sep 14, 2015
new Grammar in 740 - internal table filter
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