Hi
I have an issue with locate in dataset and can shrink it to following simple example:
Source is:
procedure TForm2.createbtnClick(Sender: TObject);
begin
testdata.FieldDefs.Clear;
testdata.FieldDefs.Add('id',ftinteger);
testdata.FieldDefs.Add('user',ftstring);
testdata.AddIDBIndex('id','id');
testdata.IDBActiveIndex:='id';
testdata.active:=true;
end;
procedure TForm2.addbtnClick(Sender: TObject);
begin
testdata.insert;
testdata.fieldbyname('id').asinteger:=4711;
testdata.fieldbyname('user').asstring:='testuser';
testdata.post;
end;
procedure TForm2.recccountbtnClick(Sender: TObject);
begin
weblabel2.Caption:='Recordcount='+inttostr(testdata.RecordCount);
end;
procedure TForm2.locatebtnClick(Sender: TObject);
begin
if testdata.locate('id',4711,[]) then
weblabel3.caption:=testdata.fieldbyname('user').asstring
else
weblabel3.caption:='4711 not found';
end;
procedure TForm2.testdataAfterInsert(DataSet: TDataSet);
begin
weblabel1.Caption:='4711 testuser inserted';
end;
The problem is:
Create db runs ok
Add record runs ok
get recordcount counts ok
but locate does not find id 4711
Why ?
All calls are asynchron.
Result on my computer is:
What am i doing wrong ?
Regards
Peter