Solved

DBGRID usage

Posted on 2000-04-09
8
339 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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 101
FMX and jaudiotracker playing memory stream 29 79
Delphi Yen format 3 35
Slow Restore if incremental backups using RDiff.exe 4 21
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

831 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