Solved

Tdataset lookup example

Posted on 2004-08-21
6
2,815 Views
Last Modified: 2010-04-05
I am looking for a usage example of the TDataset.lookup method (code snippet).  Thanks!
0
Comment
Question by:billseven
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 63 total points
ID: 11862512
Hello

  First Paramter is the field you want to search in, second parameter the value, and last parameter the field that you want to have it's value based on search on first parameter

procedure TForm1.Button1Click(Sender: TObject);
var
 V : Variant;
begin
  V := Table1.Lookup('CustNo','1231','Company') ;
  ShowMessage(V);
end;

Remember, Lookup method doesn't move the Pointer to the found record, it's just give you the result, if you would like the pointer to move for the found record, use Located instead of it,

HTH

Regards,
Mohammed
0
 
LVL 12

Assisted Solution

by:esoftbg
esoftbg earned 62 total points
ID: 11862818
download a working example from:
page:        http://www.geocities.com/esoftbg/
  link:        Q_21102337.zip

//....................................

procedure TForm1.Button1Click(Sender: TObject);
var
  V: Variant;
  C: Integer;
  A: String;
begin
  V := Table1.Lookup('Company;State', VarArrayOf(['Blue Sports', 'OR']), 'CustNo;Addr1');
  if (VarType(V) in [varNull]) then
    ShowMessage('Search unsuccessful !')
  else
  begin
    C := V[0];
    A := V[1];
    ShowMessage(IntToStr(C) + #10 + A);
  end;
end;
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 13356440
split points
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 124
URL for downloading Google Chrome for Win XP 2 279
Performance of SQL statement 37 146
Delphi Yen format 3 72
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question