Page 1 of 1

Using the Locate with a Table

Posted: Fri 29 Apr 2005 10:26
by el_ade
I have the following procedure

procedure TFHotInventariosIngresaTarifas.cxButton1Click(Sender: TObject);
var
FecMod : TDateTime;
begin
FecMod := EditFecIni.Date;
while Fecmod <= EditFecFin.Date do
begin
FHotInventarios.TTarifas.Locate('fecpre',DateTimeToUnix(FecMod),[]);
FecMod := IncDay(Fecmod,1);
end; //while
end;

But in the locate line it raise an Access Violation, I think perhaps I´m using the wrong way the locate method (I have many hours with this problem) the DateTimetoUnix was a try to see if this thing works, but doesn´t

The main idea is locate a certain date, and if it does not exist the insert a record or if exists, then update the record.

somebody has an idea?

Thank you

Posted: Fri 29 Apr 2005 14:04
by Ikar
Try to remove DateTimeToUnix function. If 'fecpre' is TDateTime field this function call is not necessary.

Posted: Fri 29 Apr 2005 17:10
by el_ade
The Result is the same,
"Access violation at address 0041D233"

FHotInventarios.TTarifas.Locate('fecpre',FecMod,[]);

I have even tryed to use the locate with other fields, with the same access violation.

Could it be a bug in the TMyTable? I´m using Delphi 2005 with windows XP and the mySQL database is remotelly connected

Posted: Wed 04 May 2005 06:23
by Ikar
We couldn't reproduce the problem.
Please send us complete small sample to demonstrate it and include script to create and fill table.