Hi John TDatset.FieldByName is slow - and you're repeating it 15,000X5 times.
Much better to declare 5 TField type vars, use TDataSet.FindField or TDataSet.FieldByName to assign them prior to the loop. See how you get on. Cheers D On Thu, 6 Dec 2007 15:35:49 +1300, you wrote: >I want to use TClientDataSet for data that is NOT in a database. > >Just reading the data from a file, eg for 15000 records, takes much less >than a second, but reading the data and inserting several fields into a >client dataset in a simple loop takes a lot longer, eg 6 seconds or more for >the same 15000 records. > >The code I am using is like: > > with tbData do > begin > append; > fieldbyname('FieldName1').asInteger:=Number1; > fieldbyname('FieldName2').asInteger:=Number2; > fieldbyname('FieldName3').asInteger:=Number3; > fieldbyname('Name').asString:=Name; > fieldbyname('Desc').asString:=Desc; > post; > end; > >I would like to speed this up, as I have seen that reading similar data from >a Database eg with a query is much faster. Any suggestions to speed this >up? > >I already have lines in such as > > tbdata.DisableControls; > tbdata.EnableControls; > >Before and after I start reading the data to stop screen updates.... > >John > > >_______________________________________________ >NZ Borland Developers Group - Delphi mailing list >Post: delphi@delphi.org.nz >Admin: http://delphi.org.nz/mailman/listinfo/delphi >Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe _______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe