Board index » delphi » Bestway to view info from 2 tables

Bestway to view info from 2 tables

I have 2 tables that have related data .in each in the first table I have
employee profiles which includes an Employee_id. I have a second table
called transactions which include includes the Employee_id and Transactions.
I want to be able to do two things, When I select the employee from the
profile I want to display just that employees transactions in the best way,
and secondly If I delete the the employee from the profile I want all his
records deleted in the transactions table. I am using the DBNAV to Navigate
and DBgrid to display the data. I am using ADO table and connect components.

Thank you in advance

Dave

 

Re:Bestway to view info from 2 tables


Quote
>I have 2 tables that have related data .in each in the first table I have
>employee profiles which includes an Employee_id. I have a second table
>called transactions which include includes the Employee_id and Transactions.
>I want to be able to do two things, When I select the employee from the
>profile I want to display just that employees transactions in the best way,
>and secondly If I delete the the employee from the profile I want all his
>records deleted in the transactions table. I am using the DBNAV to Navigate
>and DBgrid to display the data. I am using ADO table and connect components.

What databse are you using?
TAdoTable is usualy not a good component for displaying data.
You should be able to link your Transaction table to the Profile table using
Ttable MasterSource and Masterfields property.

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Bestway to view info from 2 tables


Thanks Brian That did help I am able to eliminate a query.

Now is there a simple way for the transaction table information associated
with a employee id to be deleted if I delete the employee including his ID
from the profile table or do I just need to write a SQL statement.

By the way Im using Microsoft SQL Server for the database..

Thanks

Dave

Re:Bestway to view info from 2 tables


Quote
>Now is there a simple way for the transaction table information associated
>with a employee id to be deleted if I delete the employee including his ID
>from the profile table or do I just need to write a SQL statement.

>By the way Im using Microsoft SQL Server for the database..

Write a Delete Trigger for the Employee table that will delete from the
transaction table.
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Bestway to view info from 2 tables


Quote
<d...@digitalks.com> wrote in message news:3d1b3b24$1_1@dnews...
> Thanks Brian That did help I am able to eliminate a query.

> Now is there a simple way for the transaction table information associated
> with a employee id to be deleted if I delete the employee including his ID
> from the profile table or do I just need to write a SQL statement.

> By the way Im using Microsoft SQL Server for the database..

If you are using SQL Server 2000, you can set up a foreign key from the
transaction table to the employee table, and specify ON CASCADE DELETE which
will automatically delete all the transaction records when an employee is
deleted.

Andy Mackie.

Re:Bestway to view info from 2 tables


Andy that worked great

Thanks

Re:Bestway to view info from 2 tables


Andy that worked great

Thanks

Other Threads