Menu

#76 GetNewID on TVpCustomDBDataStore.LoadContacts

open
nobody
DataStores (19)
5
2013-01-15
2003-09-30
Anonymous
No

I cannot understand why you use GetNewID (just like if
you were creating a new record in the table when you'r
just loading the data in memory to display them) when
you load contacts, tasks or events on changing the
ressource in the combobox.
This results in a incontrolable growing of the IDs in the
IDTable and in a unbearable slow loading of contacts
when you begin to have lot of records in the table.

I have replaced the following code :
procedure TVpCustomDBDataStore.LoadContacts;
var
Contact: TVpContact;
begin
if (Resource <> nil) then
with ContactsTable do begin
SetFilterCriteria(ContactsTable, False,
ResourceTable.FieldByName
('ResourceID').AsInteger,
0, 0);
First;
while not EOF do begin
Contact := Resource.Contacts.AddContact
(GetNextID(ContactsTableName));

by this one :

procedure TVpCustomDBDataStore.LoadContacts;
var
Contact: TVpContact;
begin
if (Resource <> nil) then
with ContactsTable do begin
SetFilterCriteria(ContactsTable, False,
ResourceTable.FieldByName
('ResourceID').AsInteger,
0, 0);
First;
while not EOF do begin
Contact := Resource.Contacts.AddContact
(FieldByName('RecordID').AsInteger);

Now everything is working well and quick :).
Tell me if i have done something wrong

Discussion


Log in to post a comment.