Solved

DBGRID usage

Posted on 2000-04-09
8
338 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 253
Help to pass a value through a function 2 64
Intraweb download file link ? 1 89
find a node in VST 2 47
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…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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