#1 Re: Source Code repository » TSynBigTableMetaData 's .Delete() method crashes the entire file??? » 2015-07-07 02:03:01

This is the code for insert to the table

      SetString(tmp,PAnsiChar(MS.Memory),MS.Size);

      rec.Init(TF.Table);
      rec.SetFieldValue('mid', edtRecordId.IntValue );
      rec.SetFieldValue('size',Length(tmp));
      rec.Field['ext']  := LowerCase(ExtractFileExt(OpenDialog1.FileName));

      newId := TF.RecordAdd(tmp,rec);

#2 Source Code repository » TSynBigTableMetaData 's .Delete() method crashes the entire file??? » 2015-07-07 01:57:33

nextglory
Replies: 1

Dear administrator(Mr cool),

I'm currently playing on the TSynBigTableMetaData class, and I found every time when I call TF.Delete(i), It can be deleted successfully, but after I re-opened the database file using:

TF := TSynBigTableMetaData.Create(myFile,'mdata', fmShareDenyNone); 

I got error says: TFileBufferReader: invalid content,

Here is the code I use to delete the record:

procedure TForm1.refreshIDs;
var
  i,m:Integer;
begin
  m:=0;

  lstIDs.Clear;
  lstIDs.Items.BeginUpdate;

  for i:= 0 to TF.Count-1 do begin
    m := TF.NumericalID[i];
    lstIDs.Items.Add(IntToStr(m));
  end;

  lstIDs.Items.EndUpdate;
end;

procedure TForm1.btnDeleteClick(Sender: TObject);
var
  i:Integer;
begin
   i:= StrToIntDef(lstIDs.Items[lstIDs.ItemIndex],-1);

   if (i>0) and (TF.Delete(i)) then
   begin
      Caption:= Format('Deleted successful, record left is:%d',[TF.Count]);
      TF.Pack(True);
      refreshIDs;
   end
   else Caption:= 'NOT ABLE TO DELETE RECORD';
end;

why?

Thanks and have a nice day!
Andy

Board footer

Powered by FluxBB