//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "CreateDataSet.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  CDS2->LoadFromFile("../CDS2.XML");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  CDS2->SaveToFile("../CDS2.XML", dfXML);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
  CDS2->Close();
}
//---------------------------------------------------------------------------

// BeginExample: CreateDataSet
// Method: DBClient.TCustomClientDataSet.CreateDataSet
// Property: DB.TDataSet.FieldDefs
// Method: DB.TFieldDefs.AddFieldDef
// Method: DB.TIndexDefs.AddIndexDef

// BeginCode
/*
The following code creates and activates a client dataset in
the form’s OnCreate event handler.
*/ 
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  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();
}
// EndCode
// EndExample: CreateDataSet
//---------------------------------------------------------------------------

