Board index » delphi » Locate doesn't locate

Locate doesn't locate

Hi,
I encountered the following problem: when using an ADO Table or ADO Query
the locate method doesn't always work.. The key word here is "always" e.g.
in one case it works in another it does not!

Here is an example: I am using Delphi5 with the patch from Mark Edington, MS
SQL Server 7(with Service Pack1). Tables are Table1,Table2 and Table3. The
sql that fetches the data is:

select T1.*,T2.*, T3.*

from (Table1 T1 join Table2 T2 on T2.ID_T1=T1.ID

         left join Table3 T3 on T2.ID_T3=T3.ID)

where

  <and here some where clauses>

After opening the query I try to locate on same of the fields, for example
the fields Name and Surname. Here is the locate code:

QrJoin.Locate('NAME', 'some name here', [loPartialKey])  // I tried without
locate options too

The strange thing is that Locate locates correctly when used on field
Surname, but it doesn't on field Name. Both fields are VarChar(15), and both
are not indexed.

I tried both CursorLocations and it doesn't help neither. I see that the
"Name" I try to locate is there but the Locate function simply doesn't
locate it!

I noticed that Lookup ('NAME', 'Some name here', 'ID') returns the correct
ID.

Then I indexed the Name field and tried the seek method. that didn't work
too.

Please help. It is very urgent!!!

10x in advance. E

 

Re:Locate doesn't locate


Quote
>The strange thing is that Locate locates correctly when used on field
>Surname, but it doesn't on field Name. Both fields are VarChar(15), and
both
>are not indexed.

I ran into a similar problem.  Evidently somewhere in the process, some
service sees "NAME" as a reserve word.  In my case it also happened with a
column called "POSITION."  I don't know where it gets tagged (in my case it
might have been Access but I am not sure), but it only happens in ADO...BDE
works OK.  I changed the column names and everything works OK.

I know it's a hassle but try to rename your column to something like
"FULLNAME."  It should work.

I spent about 3 weeks on this problem.

Re:Locate doesn't locate


Thanx J.M.
but it seems that this is not exactly the problem. I changed the field form
Name to FullName and it actually worked :)).. i am now able to locate on
this field, but here comes another problem: I have another Table which has a
field "Room_Num". I use an Ado TTable to acess this table, and when I try to
locate on Room_Num sometimes the location is correct and sometimes it is
not!!! Let's say that Room_Num is:
    3C
    4P
    101
    102
    ....
    119
    ...
    604
.....,...... and so on
Locate locates correctly the 119 room (only!!!) but if you try to locate
room_num=604 (or any other) the cursor is position on the first (!!!)
record.. Room_Num is a VarChar(6). Any ideas why is this happening? (I don't
think that Room_Num is any reserved word in some internal routine :)))

I forgot to mention that I am using cyrilic charset.. could this be the
problem?

Best regards: E

"J. M. De Moor" <jmdem...@nospamobjectpac.com> wrote in message
news:81v8qf$c7a12@forums.borland.com...

Quote

> >The strange thing is that Locate locates correctly when used on field
> >Surname, but it doesn't on field Name. Both fields are VarChar(15), and
> both
> >are not indexed.

> I ran into a similar problem.  Evidently somewhere in the process, some
> service sees "NAME" as a reserve word.  In my case it also happened with a
> column called "POSITION."  I don't know where it gets tagged (in my case
it
> might have been Access but I am not sure), but it only happens in
ADO...BDE
> works OK.  I changed the column names and everything works OK.

> I know it's a hassle but try to rename your column to something like
> "FULLNAME."  It should work.

> I spent about 3 weeks on this problem.

Other Threads