Click here to Skip to main content
15,902,634 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using vb2005

I've a form with a one to many relationship. The 'many' table is displayed in a datagrid.

When I click the add new button on the binding navigator. A new blank record is created. After filling the fields on the 'one' table, I move on to the 'many' table which is a datagrid to fill in the fields. After filling the first line in the datagrid, I move on to the second line in the grid but the first line in the datagrid disappears. However, when click on the save button , the record in the datagrid reappears.


Let's say I've Department table with (Dept Id, Description) related to Section Table (Dept Id, Sect Id, Section description). One department can have many section.
I've painted the Department fields and the Section fields in a datagrid.
After creating a Department, I move on to the section grid to enter the sections (without clicking the store button). After entering the first section ID , I try to enter the second section Id. But when I click on the second row in the datagrid, the previously entered row disappeared. However when I click the store button, the previously entered section re-appears.
Any idea why?


Can you anyone tell me what is missing when designing one-to-many relationship?

Thanks
Posted
Updated 24-Jul-11 2:08am
v2

1 solution

In the relational database (one to many relationship) you need to add records step by step. For example, if you want to collect information about cars, you need to build database like this:
TABLE TypesOfCars (TypeID, Note) - relation: one
TABLE CarProducers (ProducerID, Name) - relation: one
TABLE Cars (Name, TypeID, ProducerID) - relation: many (of TypeID and many od ProducerID; foreign keys)
In the table Cars you have 2 fields which source is comming from other table.
To add record to table Cars you need to know TypeID and ProducerID. Until TypeID and ProducerID not exists, you can't add new car into your database. You need to add Type and Producer first (before add new car)!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900