Solved

DBGRID usage

Posted on 2000-04-09
8
341 Views
Last Modified: 2010-04-04
Hello ....

How can I do the following ....

I have two tables that are related as such: Table1 and Table2 have a
one-to-many relationship .... ie. Table2 can only be saved once there exists
an associated record in Table1.

I want to be able to capture records within a dbgrid for table2 (not with
direct editing the grid though ... but with selecting from dblookupcombo
boxes and then
populating a row). At this point in time though ...there is no record saved
in table 1 yet.

How do I populate the dbgrid without an active datasource? And how do I
eventually save the dbgrid records to the database (when the values
displayed in the
grid is not the values I want saved??? I want their keys saved instead?)

PS. I also want to use that same dbgrid for viewing the data later on and
maybe adding another record to table 2?

Please, any help will be appreciated.

ffelaar
0
Comment
Question by:ffelaar
  • 4
  • 3
8 Comments
 
LVL 7

Expert Comment

by:Motaz
ID: 2697539
I think it is better to split your question and ask one by one
Motaz
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2697544
It was difficult to understand what you need, but it seems I guessed what about you asked.

Tell me if I'm wrong.

You need to see in dbgrid not IDs but its associated data from another table. You want to add/edit rows in dbgrid then save it to table (I mean IDs). Right?

----
Igor.
0
 

Author Comment

by:ffelaar
ID: 2697610
To ITugay,

Well you have guessed right .... in addition to that I mentioned the relationship between the two tables.

ffelaar
0
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!

 
LVL 9

Expert Comment

by:ITugay
ID: 2697651
Ok, let's go.

Use TQuery instead TTable. You will be able to show data in DBGrid more then from one table by easy way. Then show to user another dbgrid which contains available to inserting data. Provide methods to user be able to choose row from second dbgrid and insert or replace data in first dbgrids DataSet. Do not forget reopen first dataset to see last changes.

Thats all.
-----
Igor.

0
 

Author Comment

by:ffelaar
ID: 2697665
Igor,

I am actually using TQuery and not TTable. Is there no way I can actually use only one dbgrid?

ffelaar
0
 
LVL 9

Accepted Solution

by:
ITugay earned 100 total points
ID: 2697684
Yes, it possible. Then You need to use cached update with TUpdateSQL (joined from more then one table query is not ediatable). Another way is to use one table query with lookup field (FieldKind=fkLookUp).
------
Igor.
0
 

Author Comment

by:ffelaar
ID: 2820697
Hello ITugay,

Thank you, that is exactly what I ended up doing and it is working quite nicely. I appreciate it hey.
Full points and an A for you.

Fats
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2820725
thanx Fats;)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP preg_replace code convert to Delphi 14 79
Installshield for Embarcadero EX 10.1 Berlin 4 72
Delphi Seattle StructureView color 1 21
Delphi android app hide keyboard 3 39
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

685 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