Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 27th, 2006, 11:25 PM
Registered User
 
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to convergent7
Default How-To: Form to insert recs in a One-to-Many


I'm building a shipping system that has a one-to-many relationship. I want the user to create the shipping header (who, where, when, etc)....then select all the items on the shipment...then press submit to create the shipment.

So I can create it in two-parts where they enter the header details, insert the rec then create the child records but this it too messy. The primary key between the 2 tables is an autogenerated number. What I want is the user to be able to create it all on one form or via a wizard...but the challenge I can't figure out is how to connect the two since the key is autogenerated. How do I insert the parent, then find the key and then insert the child recs?

Thanks for any guidance!


Thanks,
Erik
 
Old June 28th, 2006, 01:11 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

what DB are you using?

 
Old June 28th, 2006, 05:15 PM
Registered User
 
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to convergent7
Default


Currently it's an Access db for now...I will be moving it to a SQL one in the near future.

Thanks!

Thanks,
Erik
 
Old June 28th, 2006, 10:17 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I'm not familiar with Access. With sql server there is @@Identity and Scope_Identity that will give you the Identity(auto generated) value of the last inserted row. Then you can send this value back to the front end, and use it for the Insert into the child table.

 
Old July 15th, 2006, 03:18 PM
Registered User
 
Join Date: Jun 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to convergent7
Default


Thanks, I'm upgrading to SQL Express now so I will give that a try.

Thanks,
Erik
 
Old July 15th, 2006, 10:58 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Good luck :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Trigger for new recs John2112 SQL Server 2000 4 March 30th, 2007 05:02 AM
"Insert into - checkbox value" Form connection jb_norman PHP Databases 0 July 30th, 2006 06:26 AM
Want to get number of recs without opening rs amjad_mahmood Pro VB Databases 2 August 10th, 2005 12:44 AM
How to get # of recs without opening recordset amjad_mahmood Excel VBA 0 August 9th, 2005 05:49 AM
Enumerate Master - Detail Query Recs JpJoe Access 5 May 17th, 2005 09:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.