 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
John Guest
|
Posted: Tue Oct 28, 2003 8:20 pm Post subject: Use of Locate in Delphi |
|
|
I am able to use Locate with one field, but do not understand how to use more than one field. I get an Invalid Argument error with the following:
var
Name: Variant;
begin
begin
Name := VarArrayCreate([0, 3], varVariant);
Name[0] := editLastName.Text;
Name[1] := editFirstName.Text;
Name[2] := editMI.Text;
Name[3] := meditBirthdate.Text;
end;
begin
with tblHolder do
Locate('Last_Name;First_Name;Middle_Initial', Name , [loCaseInsensitive]);
end;
end;
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Tue Oct 28, 2003 10:05 pm Post subject: Re: Use of Locate in Delphi |
|
|
You are only searching three fields but you are putting four values
into the variant array. The number of fields and values must match.
Also, please do not ask database questions without telling us what
database you are using. Most of the time we have to know before we can
answer.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| Back to top |
|
 |
John Guest
|
Posted: Wed Oct 29, 2003 8:43 pm Post subject: Re: Use of Locate in Delphi |
|
|
I modified the code to include four fields and four values. The
database is MS SQL 2000 and meditBirthdate is a masked edit field. I
tried it without the meditBirthdate value and field (datetime in SQL
2000) in case the datetime field is not working with the query. I still
get an Invalid Argument error with it written that way and with the
following:
var
Name: Variant;
begin
begin
Name := VarArrayCreate([0, 3], varVariant);
Name[0] := editLastName.Text;
Name[1] := editFirstName.Text;
Name[2] := editMI.Text;
Name[3] := meditBirthdate.Text;
end;
begin
with tblHolder do
Locate('Last_Name;First_Name;Middle_Initial;Birth_Date', Name
, [loCaseInsensitive]);
end;
end;
Any other ideas? Thank you for your help.
John
Bill Todd wrote:
| Quote: | You are only searching three fields but you are putting four values
into the variant array. The number of fields and values must match.
Also, please do not ask database questions without telling us what
database you are using. Most of the time we have to know before we can
answer.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
John Guest
|
Posted: Wed Oct 29, 2003 9:46 pm Post subject: Re: Use of Locate in Delphi |
|
|
I deleted with tblHolder do and inserted tblHolder.Locate to begin the
statement. I also removed the data field. It will run now if all data
fields in the array have data entered.
Thanks,
John
John wrote:
| Quote: | I modified the code to include four fields and four values. The
database is MS SQL 2000 and meditBirthdate is a masked edit field. I
tried it without the meditBirthdate value and field (datetime in SQL
2000) in case the datetime field is not working with the query. I still
get an Invalid Argument error with it written that way and with the
following:
var
Name: Variant;
begin
begin
Name := VarArrayCreate([0, 3], varVariant);
Name[0] := editLastName.Text;
Name[1] := editFirstName.Text;
Name[2] := editMI.Text;
Name[3] := meditBirthdate.Text;
end;
begin
with tblHolder do
Locate('Last_Name;First_Name;Middle_Initial;Birth_Date', Name
, [loCaseInsensitive]);
end;
end;
Any other ideas? Thank you for your help.
John
Bill Todd wrote:
You are only searching three fields but you are putting four values
into the variant array. The number of fields and values must match.
Also, please do not ask database questions without telling us what
database you are using. Most of the time we have to know before we can
answer.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
|
| Back to top |
|
 |
Bill Todd Guest
|
Posted: Wed Oct 29, 2003 10:58 pm Post subject: Re: Use of Locate in Delphi |
|
|
1) Never ever using Locate against a SQL database server. When you
call locate the entire record set must be transferred across the
network to the client and searched. If you want to find one or more
records with a SQL database server use a SELECT statement with a WHERE
clause.
2) Questions relating to SQL Server or any other database server,
except InterBase, should be posted in the database.sqlservers group.
This group is for desktop databases like Access and Paradox.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
|
|
| 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
|
|