1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
Doc Borland : "delsec06.faq" 08/1995
Q: "How can I view dBASE records marked for deletion?"
A: Call the following function on the AfterOpen event of the table. You Must
include DBITYPES, DBIERRS, DBIPROCS in the uses clause (maintenant BDE). To call, send as
arguments name of TTable and TRUE/FALSE depending to show/not show deleted
records. Ex:
procedure TForm1.Table1AfterOpen(DataSet: TDataset);
begin
SetDelete(Table1, TRUE);
end;
procedure SetDelete(oTable:TTable; Value: Boolean);
var
rslt: DBIResult;
szErrMsg: DBIMSG;
begin
try
oTable.DisableControls;
try
rslt := DbiSetProp(hDBIObj(oTable.Handle), curSOFTDELETEON,
LongInt(Value));
if rslt <> DBIERR_NONE then
begin
DbiGetErrorString(rslt, szErrMsg);
raise Exception.Create(StrPas(szErrMsg));
end;
except
on E: EDBEngineError do ShowMessage(E.Message);
on E: Exception do ShowMessage(E.Message);
end;
finally
oTable.Refresh;
oTable.EnableControls;
end;
end;
--------------------------------------------------------------------------------
Q: "How can I create a column in the grid to which records in a dBASE table
are marked for deletion?"
A: Create a calculated field, then for the OnCalcField event of the table
replace the calculated field you've created like so:
procedure TForm1.Table1CalcFields(DataSet: TDataset);
var
RCProps : RecProps;
Result : DBIResult;
begin
Result := DbiGetRecord(Table1.Handle, dbiNoLock, Nil, @RCProps);
If RCProps.bDeleteFlag then Table1Del.Value := 'X' else
Table1Del.Value := '';
end;
Note: You must first call the SetDelete(TTable,TRUE) function from the
previous FAQ: |
Partager