I'm using the code below to setup my FClientDataSet, but I'd like to be able
to set the ID field to a unique auto-incrementing index so no other entry
will have the same value, I was looking into the TIndexDef but I don't
really understand it, some pointers would be helpful!
TFieldDefs *pDefs = FClientDataSet->FieldDefs;
TFieldDef *pDef = pDefs->AddFieldDef();
pDef->DataType = ftInteger;
pDef->Name = "ID";
pDef->Required = true;
pDef = pDefs->AddFieldDef();
pDef->DataType = ftString;
pDef->Size = 250;
pDef->Name = "FileName";
TIndexDef *pIDef = FClientDataSet->IndexDefs->AddIndexDef();
pIDef->Fields = "ID";
pIDef->Name = "IntIndex";
pIDef->Options << ixPrimary << ixUnique;
FClientDataSet->CreateDataSet();
FDataSource->DataSet = FClientDataSet;
FClientDataSet->Active = true;
FClientDataSet->LogChanges = false;
If I could get the ID setup right I wouldn't have to worry about generating
the ID values at all and just add like
FClientDataSet->InsertRecord(ARRAYOFCONST((NULL, "Test.txt")));
like I would with php and mysql.
Thanks.