BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

'Operation is not allowed in this context'

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Charles Collins
Guest





PostPosted: Fri Jul 01, 2005 3:47 pm    Post subject: 'Operation is not allowed in this context' Reply with quote



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





PostPosted: Fri Jul 01, 2005 6:37 pm    Post subject: Re: 'Operation is not allowed in this context' Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.