?
Solved

Easy way to search database for a name

Posted on 1998-08-10
4
Medium Priority
?
228 Views
Last Modified: 2010-04-04
I'm using Delphi 3. Client/Server Suite.

1. I need answer to search database in the easy way / can you the Delphi expert help me!!!

2. Show me little code of using query with sql or paradox
0
Comment
Question by:vis
[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
4 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1361821
There are many ways to search dataset for specific data.

1) Locate method
2) Lookup method
Locate finds the first row matching a specified set of criteria and moves the cursor
to that row.
Lookup returns values from the first row that matches a specified set of criteria,
but does not move the cursor to that row.

3) You can iterate through each record in the dataset and compare record with your criteria.

4) You can use Filter property to restrict dataset

5) You can use OnFilterRecord event to restrict dataset

6) You can use SQL and TQuery.
for example.
select * from customer where customer_name = 'Vladika'  :-)

maybe more ...

0
 
LVL 5

Expert Comment

by:mayhew
ID: 1361822
vladika's number 6 answer is probably the more common approach.

At least that's the way I'd do it.  :)

Let us know if you need more detailed instructions.
0
 
LVL 3

Expert Comment

by:rickpet
ID: 1361823
or number 7

7)
SQL property//you should never use * for your field names...
Select customer_id, last_name, first_name  
from Customer
where customer_id = :customer_id//this could be a like...

Params property set to integer for customer_id

in code...

with qryCustomer do begin
  Close;
  ParamByName('customer_id').AsInteger := MyValue;
  Open;

Rick

0
 
LVL 2

Accepted Solution

by:
saar071697 earned 400 total points
ID: 1361824
You can simply search the Ttable or Tquery Component to which the dbgrid is connected to.

Example:
Put a Dbgrid, TTable and a TDatasource on your form.
Connect  the dbgrid1 to the Datasource1 (dbgrid.datasource -property)
Connect the Datasource1 to Table1 (datasource.dataset-property)

Set TTable-databasename  and TTable-TabelName, and set
active to true.
Now put a Tedit control on the form and double-click it:
Then insert the folowwing  code:


procedure TForm1.Edit1Change(Sender: TObject);
begin
 Ttable1.Locate('FieldName',Edit1.Text,[]);
end;

If the Table is indexed you can also use findKey:

 Ttable1.FindKey([edit1.Text]);

greeting daniel
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 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