Solved

DBGRID usage

Posted on 2000-04-09
8
340 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 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