LocateEx and segmented keys
Posted: Fri 04 Jul 2008 04:39
Hi,
i try to use TMSQuery.LocateEx in this way:
(SQL Server DAC 4.50.0.35, BDS (Delphi) 2007, connect to northwind - DB SQL-Server 2000)
In documentation i read:
It seems, the second field is unused for finding the record.
Is it a problem especially with datetime - columns or do i sth. wrong ?
Thanks
Tino
P.S. Demo - App is available if needed.
i try to use TMSQuery.LocateEx in this way:
(SQL Server DAC 4.50.0.35, BDS (Delphi) 2007, connect to northwind - DB SQL-Server 2000)
Code: Select all
Var empID:Integer;
date:TDateTime;
MSQuery1.SQL.Text:="SELECT * FROM Orders ORDER BY EmloyeeID,OrderDate";
MSQuery1.IndexFieldNames:="EmployeeID;OrderDate";
MSQuery1.Open;
empID:=4;
date:=StrToDate('01.01.1997');
MSQuery1.locateEx('EmployeeID;Orderdate',VarArrayOf([empID,date]),[lxNearest])
Code: Select all
Sample - Data in Orders:
empID, Orderdate
...
3 , 30.04.1998
4 , 08.07.1996
....
4 , 20.12.1996
4 , 03.01.1997
...
I expect, that my locateEX() - statement positions at [4, 03.01.1997], but it sets the pointer to [4,08.07.1996] - the first record with employeeID = 4lxNearest
LocateEx moves the cursor to a specific record in a dataset or to the
first record in the dataset that is greater than the values specified in
the KeyValues parameter. For this option to work correctly the dataset should be sorted by the fields the search is performed in. If the dataset is not sorted, the function may return a line that is not connected with the search condition
It seems, the second field is unused for finding the record.
Is it a problem especially with datetime - columns or do i sth. wrong ?
Thanks
Tino
P.S. Demo - App is available if needed.