Subject Another Simple question
Author Dion
Hi,

Is there conceptually anything wrong with my layout. I want the loop to
continue processing for the duration of the table length. Errors must be
trapped in the exception part and must be written to a text file. There are
approx 1000 records, but on the first error, I get 'end of dataset' error. I
am reading from a Source table and copying to a Target table(this is only
part of the bigger app).

AssignFile(ErrorFile, 'ErrorFile.txt');
ReWrite(ErrorFile);

try
counter := 0;

qrySourceMembers.First;
while not qrySourceMembers.EOF do
begin

if not IB_Transaction1.InTransaction then
IB_Transaction1.StartTransaction;

{ add member to target db }
with qryTargetMembers do
begin
Append;

FieldByName('MEMBERID')
.Assign(qrySourceMembers.FieldByName('MEMBERID') ) ;
FieldByName('TITLEID ')
.Assign(qrySourceMembers.FieldByName('TITLEID') ) ;
FieldByName('INITIALS')
.Assign(qrySourceMembers.FieldByName('INITIALS') ) ;
FieldByName('FIRSTNAME')
.Assign(qrySourceMembers.FieldByName('FIRSTNAME') ) ;
FieldByName('SURNAME')
.Assign(qrySourceMembers.FieldByName('SURNAME') ) ;
FieldByName('DOB')
.Assign(qrySourceMembers.FieldByName('DOB') ) ;

try
qryTargetMembers.Post;

except on E:Exception do
if IB_Transaction1.InTransaction then
IB_Transaction1.RollBack;

end;

if IB_Transaction1.InTransaction then
IB_Transaction1.Commit;

qrysourcemembers.next;
end;

finally
CloseFile(ErrorFile);
end;

Many Thanks,
Dion.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.314 / Virus Database: 175 - Release Date: 01/11/2002