Solved

Database Navigation

Posted on 2004-03-23
10
209 Views
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 ?`

thanks
fuluppi

any code is appreciated
0
Comment
Question by:fuluppi
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 1

Expert Comment

by:rbarlow
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.

SELECT *
  FROM Customer
 WHERE
    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.

Regards,
Raymond Barlow
0
 

Author Comment

by:fuluppi
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 ?

thanks
fuluppi
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 250 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 := '........';
and
TableCustomers.Filtered := True;

emil
0
 
LVL 27

Expert Comment

by:kretzschmar
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 ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10661701
hi emil, a bit faster :-))
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

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

Author Comment

by:fuluppi
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 :-(
0
 
LVL 27

Expert Comment

by:kretzschmar
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 ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 10662320
btw. missed some + above :-))
0
 

Author Comment

by:fuluppi
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 ;-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

914 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now