Solved

DBGRID usage

Posted on 2000-04-09
8
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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