BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: ADOTable.Locate Workaround?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Chris LeFebvre
Guest





PostPosted: Fri Feb 27, 2004 5:01 pm    Post subject: Re: ADOTable.Locate Workaround? Reply with quote



Hi Brian:
Thanks for the tips, but I do have an odd problem here.. you mention
that TAdoTable.Locate has problems when there's a filter applied and my
problem is that I'm not using any filters and locate consistently
doesn't find records that I know are there.

For example, the table RegInfo has an numeric field called ID and
using this hard coded locate:
RegInfo.First;
RegInfo.Locate('ID', VarArrayOf([104]), []);
the locate returns false (no matching records) when I know for a fact
that there's a record with an ID number of 104. Before I start making
major changes I'd rather see if this can be made to work, any idea's?

Thanks,

- Chris LeFebvre

Back to top
Vassil Nazarov
Guest





PostPosted: Fri Feb 27, 2004 7:24 pm    Post subject: Re: ADOTable.Locate Workaround? Reply with quote



Chris,

Quote:
RegInfo.Locate('ID', VarArrayOf([104]), []);

VarArrayOf is intended to be used with multiple fields only.
RegInfo.Locate('ID', 104, []); should work fine.

HTH
--
Vassil Nazarov
http://web.orbitel.bg/vassil/



Back to top
Chris LeFebvre
Guest





PostPosted: Sat Feb 28, 2004 6:21 am    Post subject: Re: ADOTable.Locate Workaround? Reply with quote



I see, said the blind man... that works fine, thanks for the help
Vassil.

Regards,

- Chris LeFebvre

Back to top
Chris LeFebvre
Guest





PostPosted: Mon Mar 01, 2004 4:59 pm    Post subject: Re: ADOTable.Locate Workaround? Reply with quote

Hi Brian:
As I mentioned to Vassil, (and) as you indicated I've gotten Locate to
work on the ID field with this:
KValue: Varient;
KFields: String;
Options: TLocateOptions;

Options := []; kFields := '';
If cbPartial.Checked Then Include( Options, loPartialKey );
If cbCaseSens.Checked Then Include( Options, loCaseInsensitive );
KFields := 'ID';
KValue := VarArrayCreate( [0,0], VarInteger );
KValue := StrToInt(edID.Text);
RegInfo.Locate( KFields, KValue, Options );

however I've run into two other problems that I can't seem to figure out,
first the above works fine for a single integer value but if I use
something similar for a single string value such as:
KValue: Varient;
KFields: String;
Options: TLocateOptions;

Options := []; kFields := '';
If cbPartial.Checked Then Include( Options, loPartialKey );
If cbCaseSens.Checked Then Include( Options, loCaseInsensitive );
KFields := 'ID';
KValue := VarArrayCreate( [0,0], VarString );
KValue := StrToInt(edID.Text);
RegInfo.Locate( KFields, KValue, Options );

according to help VarString is a valid varient type code however I get
"error creating varient array" when executing "KValue := VarArrayCreate(
[0,0], VarString );", my experience with varients has been somewhat
limited so any ideas why this works for a integer but not for a string?

The second problem is when I use this code for a multiple field locate:
KValue: Varient;
KFields: String;
Options: TLocateOptions;

Options := []; kFields := '';
If cbPartial.Checked Then Include( Options, loPartialKey );
If cbCaseSens.Checked Then Include( Options, loCaseInsensitive );
KFields := 'LastName;FirstName';
KValue := VarArrayCreate( [0,1], VarVarient );
KValue[0] := edLastName.Text; { for example Wri }
KValue[1] := edFirstName.Text; { and Car, there is a Carmen Wright
record }
RegInfo.Locate( KFields, KValue, Options );

Partial and Case Insensitive are checked, but locate returns false despite
that fact that I know there's a matching record?

Thanks,
- Chris LeFebvre

Back to top
Vassil Nazarov
Guest





PostPosted: Wed Mar 03, 2004 6:57 pm    Post subject: Re: ADOTable.Locate Workaround? Reply with quote

If you want to use loPartialKey and/or multiple columns you'll
have to use TBetterADODataSet. Borland's components don't
support this.

HTH
--
Vassil Nazarov
http://web.orbitel.bg/vassil/


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.