Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Easy way to search database for a name

Posted on 1998-08-10
4
Medium Priority
?
229 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

604 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