CreateDataSet (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code creates and activates a client dataset in the form's OnCreate event handler.

Code

__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
  TFieldDefs *pDefs = CDS2->FieldDefs;
  TFieldDef *pDef = pDefs->AddFieldDef();
  pDef->DataType = ftInteger;
  pDef->Name = "Field1";

  pDef = pDefs->AddFieldDef();
  pDef->DataType = ftString;
  pDef->Size = 10;
  pDef->Name = "Field2";

  TIndexDef *pIDef = CDS2->IndexDefs->AddIndexDef();
  pIDef->Fields = "Field1";
  pIDef->Name = "IntIndex";

  CDS2->CreateDataSet();
}

Uses

See Also