 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris LeFebvre Guest
|
Posted: Fri Feb 27, 2004 5:01 pm Post subject: Re: ADOTable.Locate Workaround? |
|
|
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
|
Posted: Fri Feb 27, 2004 7:24 pm Post subject: Re: ADOTable.Locate Workaround? |
|
|
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
|
Posted: Sat Feb 28, 2004 6:21 am Post subject: Re: ADOTable.Locate Workaround? |
|
|
I see, said the blind man... that works fine, thanks for the help
Vassil.
Regards,
- Chris LeFebvre
|
|
| Back to top |
|
 |
Chris LeFebvre Guest
|
Posted: Mon Mar 01, 2004 4:59 pm Post subject: Re: ADOTable.Locate Workaround? |
|
|
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
|
Posted: Wed Mar 03, 2004 6:57 pm Post subject: Re: ADOTable.Locate Workaround? |
|
|
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 |
|
 |
|
|
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
|
|