Can't Delete Records from an MS Access DB
- From: Larry Dew <ldew@xxxxxxxxxx>
- Date: Wed, 17 May 2006 11:17:01 -0500
I am trying to use the following code to remove a group of records from an TAdoTable connected to an MS Access DB. When I evoke the DeleteRecord I receive an exception the "Operation is not allowed in this context".
Do I have to set the cursor type? I have tried entering "Edit" mode but I still get the error. What am I not doing? I do not know enough SQL to delete the records directly from the DB. If that would be better I would need some instruction.
The DM is the datamodule where the ADOConnections components live. 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 }
.
- Follow-Ups:
- Re: Can't Delete Records from an MS Access DB
- From: Brian Bushay TeamB
- Re: Can't Delete Records from an MS Access DB
- Prev by Date: Re: Red squigglies in D2006
- Next by Date: Re: Connection to Access Database Problem
- Previous by thread: Red squigglies in D2006
- Next by thread: Re: Can't Delete Records from an MS Access DB
- Index(es):
Relevant Pages
|