473,769 Members | 1,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2150
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
3089
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 words, their own definitions plus an example of how the word is used in practice. It'll be all client side with - cookies? to get persistence so that the words won't disappear on me each time the page is closed (which is what happened when I
2
4174
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 queries that join different tables. I need to create a new record in form 2 by pulling the ID over__I have that part done-- and 2 fields over and filling in on form 2. The record source between the 2 forms cannot be joined except by a many to many...
5
3752
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 Office 2000. I am creating a database to track student athletes. I have created the following tables. The table title is to the far left, with fields under each. The common field will be the StudentID field, which is their student number assigned...
0
1387
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 area. The relationship is many to many. One is a master form and the other I dragged in to be a subform. I also created a child/master link based on the common "number" field. So, it's a generic subform pretty much.
3
2820
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: http://support.microsoft.com/?kbid=304473 I referred to the part in it that says:
4
3621
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 writing an accounting application. I have a chart of accounts in the form of a containment hierarchy. A GeneralLedger contains a number of Accounts, and each of these Accounts can contain a Aubledger, which contains its own Accounts, and so on. The...
1
1677
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 currently as follows...
6
4871
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 why. I've been exploring using Access as a front end to both SQL MSDE and Oracle XE. I'm in the process of writing a class to handle the basics of the ADO connection and recordsets. The basic relationships are as follows:
11
10623
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 Author_ID (Primary Key), First_Name and Last_Name. Both tables will be expanded later, after I have solved my current problem Because one book can have multiple authors, and because one author can have several books, I want to use a many-to-many...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9415
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10198
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9848
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8860
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3947
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.