 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Charles Collins Guest
|
Posted: Fri Jul 01, 2005 3:47 pm Post subject: 'Operation is not allowed in this context' |
|
|
I'm just starting with ADO and have a simple program I am trying to write.
Delphi 7 Enterprise, standard ADO components, MS Access database.
I have a table that I want to empty and then refill from a CSV file. I have
defined a table and a connection.
CabInfo: TADOTable;
ADOConnection1: TADOConnection;
with fields
CabInfoCabID: TWideStringField;
CabInfoLeasor: TWideStringField;
CabInfoYear: TWideStringField;
CabInfoMake: TWideStringField;
CabInfoModel: TWideStringField;
I have tried to empty the table with this code:
CabInfo.Active := False;
CabInfo.LockType := ltBatchOptimistic;
CabInfo.Active := True;
CabInfo.DeleteRecords(arAll);
CabInfo.UpdateBatch(arAll);
but it returns the error "Operation not allowed in this context". Once I
get the table to empty, I will be reading the CSV file and parsing each line
into the table's fields.
The update statement occurs after parsing a line from the CSV with the code:
CabInfo.InsertRecord([WkCab,WkLeasor,WkYear,WkMake,WkModel]);
I have used similar procedures to update Paradox tables, but am at a loss to
determine how to correctly process the Access table via ADO. I have read
the Delphi 7 ADO components, but not found anything I can state is out of
line.
Help, Please?
|
|
| Back to top |
|
 |
Charles Collins Guest
|
Posted: Fri Jul 01, 2005 6:37 pm Post subject: Re: 'Operation is not allowed in this context' |
|
|
For those wanting a result, add a Command component:
MyCmd: TADOCommand;
and instead of using the DeleteRecords, use a routine like this:
CabInfo.Active := true;
MyCmd.CommandText := 'Delete * from CabInfo';
MyCmd.Execute;
CabInfo.Active := false;
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|