Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Findkey Problems

Status
Not open for further replies.

marieannie

Programmer
Jan 14, 2004
84
US
Hi, I'm using Advantage as database in delphi 5.0
I have an Index in which the keys are 2 fields of one table. When using this index, I try to use the instruction Findkey and doesn't find the register. (And I give the correct info) ~ I found that the problem is, for example, that one of the fields are declared as Character of 20, but the info only use 10 characters, the other characters are empty and the findkey doesn't work. (I made a test filling all the posible characters and the findkey instruction worked). I don't know how if there is a way to fix this problem. The one that I'm want to try is to fill the empty characters with a space. I try to use PADL to do this but Delphi shows this error [Error] cfacycod.pas(8550): Undeclared identifier: 'PADL'

I'm not sure if using PADL is the better way to fix this.
Any other suggestions?

Hopefully someone understand what I'm trying to say.... Sorry about my english....


Thanks for your help
 
I don't use Advantage, but .....
why don't you use query instead of table?

'select * from table where field1 = "xxx" and filed2 = "yyyy"'

I hope this works !!!

Alternatively try with Advantage techincal support at:


i'm afraid it's a problem with batabase configuration.

I never had such a problem with any database i worked on.


Giovanni Caramia
 
Try using FindNearest instead of FindKey.

Andrew
Hampshire, UK
 
Personally, I do use the Advantage database and I use EditKey instead of FindKey. The problem with Advantage is that it is particularly sensitive to field types. If your field is a string, then you need tp search using a string, it wont do the work for you. Try adapting the following code and see if it works for you.

Code:
Table1.Close;
Table1.IndexName := 'MyIndex';
Table1.Active := True;
Table1.EditKey;
Table1.FieldByName('FIELD1').AsInteger := MyInteger;
Table1.FieldByName('FIELD2').AsString := MyString;
Table1.GotoKey;

Also, as Im writing this off the top of my head, I cannot recall whether the string field would need to be a quoted string. If it does then the second fieldbyname line would simply read :-

Table1.FieldByName('FIELD2').AsString := QuotedStr(MyString);

[blue]"Now you see that evil will always triumph, because good is dumb" - Dark Helmet[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top