Re: Can't Delete Records from an MS Access DB



Brian Bushay TeamB wrote:
AllocationID is an Indexed (dup=YES) field.

Tbl := TADOTable.Create( Self );
try
with Tbl do // return all records with the AllocationID
begin
Connection := DM.Allocations;
TableName := 'Allocated';
Filter := format( 'AllocationID = %d',[AllocationId]);
Filtered := TRUE;
Open;
if (RecordCount > 0) and Supports( [coDelete] ) then
DeleteRecords(arAll);
end;
finally
Tbl.Free;
end; { try/finally }

The ArAll option doesn't work with DeleteRecords.

To do this with SQL user a query like this


AdoQuery1.SQL.clear;
AdoQuery1.sql.add('Delete from Allocated where AllocationID =
'+quotedStr(AllocationId) )
--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
Thanks for the help. The Help file indicates that the default value for DeleteRecords is arAll. I tried arFiltered and received the same message. What is the "Context" referring too?
.



Relevant Pages

  • Cant Delete Records from an MS Access DB
    ... When I evoke the DeleteRecord I receive an exception the "Operation is not allowed in this context". ... I do not know enough SQL to delete the records directly from the DB. ... with Tbl do // return all records with the AllocationID ...
    (borland.public.delphi.database.ado)
  • DeleteRecord raises and Exception
    ... When I evoke the DeleteRecord I receive an exception the "Operation is not allowed in this context". ... with Tbl do // return all records with the AllocationID ...
    (borland.public.delphi.database.ado)
  • Re: Cant Delete Records from an MS Access DB
    ... with Tbl do // return all records with the AllocationID ... Connection:= DM.Allocations; ... TableName:= 'Allocated'; ...
    (borland.public.delphi.database.ado)