473,385 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Persisting form data with one to many relationship

I'm still very new to ASP.Net, so wanted to get some advice on how to solve
the following design problem (sorry my explanation is so long):

I'm developing an ASP.Net intranet app (using VB.Net for my business
objects) that will allow my users (max of about 25) to enter information
about families and their children. On one page, I need to collect general
information about the family (such as address and phone number) and specific
information (such as name, birthdate, and much more) about one or many
children. Once ALL information is entered about the family and all
children, I'll save it all to the database (into a Family and Child table,
with Family ID being a foreign key in the Child table)

In order to allow for an unlimited number of children, I had planned to
collect the family information on the main page and display a list of any
existing children. The user could choose to edit information about one of
those existing children, or choose to add a new child. In order to add or
edit a child, I'd display a popup window with all the needed child
information.

I've done this many times in the past (using ASP Classic), but in those
cases, I always had the parent record already saved in the database before I
tried to add any children to it (e.g., the Family record was in the database
before any Children were added), so I could just have the Child popup window
save itself to the database as long as I knew the Family ID.

In this project, however, I want to save it all at once, so I need to
persist any data entered in the Children pages, along with everything
entered in the Family page. I was thinking the best thing to do would be to
just store my Family business object (with its collection of Child objects)
in the Session object, then I can update the appropriate Child object each
time the Child popup window is opened and save the entire object to the
database once the user is done.

I know in ASP Classic, however, it was not a good idea to store VB objects
in the Session. Is this true for VB.Net objects? Are there any pitfalls to
this approach that I should be aware of? Are there better design
alternatives for me to pursue?

Thanks in advance,
Diane
Nov 18 '05 #1
1 2135
First, Session management is supposed to be much improved in .NET. In larger applications, you can actually deploy separate server(s) that are dedicated to Session state storage. I've never done this, but evidently there's also a way to use SQL Server as a back-end to your session state servers

But enough of that - with only 25 users, you won't need to get that fancy - unless of course other applications running on the same server platform as your app are much larger and you have serious capacity issues

My approach would be this: As users are entering the data you're talking about, keep the data in Data Table objects. The Data Tables will all be members of a single Data Set - and you can persist this Data Set with a single Session variable. The column structure of each Data Table will match one of your actual database tables - the data set becomes sort of a mini-database of its own

You can even add data relation objects into your Data Set - for managing one-to-many relationships - and, primary keys, foreign keys, validation criteria, and all sorts of things that can help keep the data valid and correct in terms of integrity rules, etc.

When a complete set of parent/child records are ready to be permantly stored in the database, you'll execute a set of commands - via OLEDB (or SQL) DataAdapters, which manage the relatyionship between each Data Table and its corresponding database table. I would recommend getting very familiar with all of these various objects before you jump in to developing your actual application. I'll just quickly mention a couiple of things that I think tend to throw people off when working with them

1) Don't confuse Data Sets (and Data Tables) with classic ADO recordsets - they're totally different. You'll need to understand how datasets changes are tracked - the dataset has it's own methods for undoing updates - lots of interesting stuff.

2) The data relations, keys, and things you set in the data set are not a substitute for good database design. You should have good integrity rules in the DB as well. Your Data Set rules are there to help you make sure you stuff is valid before you even try to store it

If you're really, really worried about over-using session storage, consider using View State instead. A lot of people only use view state the way ASP.NET does by default - to persist web control values between round-trips. But you can store any value in ViewState (only has to be strings or integers, if I'm not mistaken.) I've never done this myself, but I think you can persist an entire dataset in ViewState - you only have to serialize it first (should be easily done with the ISerializable interface.

Good Luck
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
2
by: allyn44 | last post by:
Hello, I have a form that I need to transfer some of the info into a second form based on a different query. The Id field is the same for data sources for both forms, but are based on...
5
by: Sami | last post by:
Please bear with me, and if you answer this question, please do it step by step. I am new at Access, not at all sophisticated. I am using Office XP. This will need to be read in Access for...
0
by: Alienz | last post by:
Hey all. if anyone is REALLY bored please help moi. I am new to access stuff and am probably missing something obvious here. I have 2 tables that are linked via "number" in the relationship...
3
by: Carmela | last post by:
Hello Readers, I am trying to update data on a form that is based on a query having a many-to-one-to-many relationship. I found this exciting link that seemed to have the solution for me: ...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
1
by: Kevin | last post by:
I need some help figuring this one out. I'm sure I did something like it awhile back but I can seemed to find that database or remember how I did this. Any way, the database tables are...
6
by: Greg Strong | last post by:
Hello All, Is is possible to use an ADO recordset to populate an unbound continuous Subform? I've done some Googling without much luck, so this maybe impossible, but let me try to explain...
11
by: RobertJohn | last post by:
Hi all I am using Access 2007 to start a small home library application, and so far it has two tables. 1. Books, with fields Book_ID (Primary Key) and Title, and 2. Authors, with fields...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.