Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data entry form with a parent and child table

Status
Not open for further replies.

mellenburg

Programmer
Aug 27, 2001
77
0
0
US
I’m trying to design a data entry form in ASP.Net using c#. The database is a relational database. There are two tables, a travel events table and a travelers table. There can be multiple travelers per travel event, there’s a one to many relationship between those tables. I have created a dataset and added a table adapter for the events table. I’m not sure how to approach the travelers table. I’ve created a datagrid to hold the traveler information. However, I’m not sure how to allow the user to enter new travelers. I can’t write the travelers to the data table because I will not have written the parent record yet. How can I store the traveler information and then write it to the Traveler table once all information has been entered into the form? Has anyone created a similar application and have sample code I can view?



Matt
 
What table is the parent and which is the child.. do you have a relationship setup in the db?
What data are you showing and what do you want to enter?
Sorry, but your post is confusing.
 
The events table is the parent, the travelers table is the child table.

The user will be entering all the information that is to be stored in both tables. For example, the user will enter a travel start and end date, which goes in the events table. The user will also enter 1 or more travelers that will be stored in the Travelers table. The events table has a PK of TravelEventID, which is a FK in the Travelers table. The travelers table PK is the combination of TravelEventID and TravelerID.
 
This is more of a DB design issue than asp.net. I would structure the tables differently. I would have 3 instead of 2.

Travlers PK-TravlerID
Events PK-EventID
TravlersEvents PK-TravlerID, EventID
FK-TravlerID to Travlers table
FK EventID to Evnets table

This way, travlers and events are separate and the IDs link them together in the TravlersEvents table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top