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


Database Navigation

Posted on 2004-03-23
Medium Priority
Last Modified: 2010-04-05
hi !
i would like to make it possible for my users to search in the database
for special names or directly jump to a customer no. i use the normal
delphi 6.0 enterprise data access components from the "data control"
tab. can i do this with dbnavigator ? is it possible to show only special
result sets instead of the whole database ?`


any code is appreciated
Question by:fuluppi
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
  • 3
  • 2
  • +1

Expert Comment

ID: 10661254
There are MANY different ways for going about this. A commonly accepted way of doing this would be with 2 forms (but you could combine the functionality if you like).

Form 1 is a search form. On this form you can specify criteria by which to search for a customer. From the values entered in the criteria fields, you can run a query against the database, with parameters in the query. The query can be built either dynamically based in what fields were entered, or you can use a generic query that includes all the criteria parameters in such a way that if the user does not enter a criteria value for that field, it will not be filtered out. eg.

  FROM Customer
    Surname LIKE :Surname AND
    CustomerNo LIKE :CustNo

When setting these fields, set them to '%' if the user did not specify critera. From the results of this query, populate a grid so the user can then select one of the many results that were returned. When the user selects one of the results, then show the details of that customer on a different form.

On this second form, the user can insert new, update existing or delete existing customers.

Anyway, this is just a common way of doing this sort of thing. Best to break forms down into their areas of functionality instead of trying to bung as much as you can on one form.

Hope this helps.

Raymond Barlow

Author Comment

ID: 10661317
hi !
i know how sql querys work but i have no idea how to use them with my dbNavigator.
this stupid thing seems to access the whole database. i use aMySQL Database
with MySQLDAC, a MySQL Table and a TDataSource where my fields are connected
to. Where can i enter a criteria ?

LVL 12

Accepted Solution

esoftbg earned 1000 total points
ID: 10661691
Delphi syntax: function Locate(const KeyFields: string; const KeyValues: Variant; Options: TLocateOptions): Boolean; virtual;

example for directly jump to a customer no:
TableCustomers.Locate('Cust_Num', Edit1.Text, []);

>is it possible to show only special result sets instead of the whole database ?
yes it is possible using properties:

TableCustomers.Filter := '........';
TableCustomers.Filtered := True;

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 27

Expert Comment

ID: 10661696
>Where can i enter a criteria ?
you should provide an editbox and a button

in the buttonevent you could use a filter like

mysqltable.filter := 'yourfieldname = '+quotedstr(edit1.text);  //for stringfields
mysqltable.filtered := true;

there are also other possibilities

meikl ;-)
LVL 27

Expert Comment

ID: 10661701
hi emil, a bit faster :-))
LVL 12

Expert Comment

ID: 10661728
hi meikl, i am few seconds faster again ;-))

Author Comment

ID: 10661769
i love you all  ;-) now i just have to find out how to make a kind of full text search through
all fields. i don't want to name each field. isn't there something like
*='*test*' ? mySQLDac wants the explicit field name for the filter :-(
LVL 27

Expert Comment

ID: 10662309
>all fields. i don't want to name each field. isn't there something like
>*='*test*' ? mySQLDac wants the explicit field name for the filter :-(

you must name all fields (this could be automated)

the result of your filter should shown like

mysqltable.filter := 'yourfieldname1 like '+quotedstr('%'+edit1.text'%')+
                       ' or yourfieldname2 like '+quotedstr('%'+edit1.text'%')+
                       ' or yourfieldname3 like '+quotedstr('%'+edit1.text'%')+
                       ' or yourfieldname4 like '+quotedstr('%'+edit1.text'%')+
                       ' or yourfieldname5 like '+quotedstr('%'+edit1.text'%')+
                       ... to be continued

meikl ;-)
LVL 27

Expert Comment

ID: 10662320
btw. missed some + above :-))

Author Comment

ID: 10662423
bahhhh. i have a table with 40 fields and i'm soo lazy ;-) but if theres no other solution i have to do it

thanks a lot ;-)

Featured Post

Industry Leaders: 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

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…
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…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

609 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