How to insert into two tables at (Master table and Detail table)

I was hoping that the asp.net/learn/dataaccess would have had a tutorial for inserting into a MasterRecord and DetailRecord.

 I have a page that I am working on that is a Reciepe. The Master Record has details such as customer, mix name, create date. The Detail Records has Ingredient Name, Ingredient Amount, etc.

I have been following the DAL and BLL concept of the asp.net/learn/dataccess tutorials. Does anyone know of an example that I can follow of setting up two tables and inserting into two tables from the same Button_click event.

Thanks, John

0
jfeeney
11/12/2008 7:12:54 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

3 Replies
939 Views

Similar Articles

[PageSpeed] 10

Hi jfeeney,

You just need to remember to insert Master table first, and then to insert into Detail table. If you use ObjectDataSource control, you can do inserting in InsertMethod of it. In InsertMethod you just do inserting such as sql database action (master first, detail second). Have a try.

Thanks,


Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Qin
11/17/2008 6:52:27 AM

Hi thanks for the reply. I have been working in that directions. However, I thought I would have to put saving to the Master File in InsertMethod. Then I thought I would have to check on_Inserted to see if I got back a item id for the Master Record. If i did then I was going to save the detail records.

From your post you make it sound that I would do both in the same InsertMethod. My Insertmethod is looking at my Business Layer (MixingRecordBLL).

0
jfeeney
11/18/2008 2:46:27 AM

Hi jfeeney,

If you handle inserting in Click event of Button, you do not have to handle InsertMethod. You can do inserting master table first and get id, then do inserting for detail table in Click event (step by step). It is free to you to do any database action there. But I think it can both work, if you put the code in Click event into InsertMethod of ObjectDataSource. You just need to make sure insertMethod can be fired,when clicking save button.

Thanks,


Qin Dian Tang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Qin
11/18/2008 3:04:21 AM
Reply:

Web resources about - How to insert into two tables at (Master table and Detail table) - asp.net.presentation-controls

Insert key - Wikipedia, the free encyclopedia
The Insert key (often abbreviated INS ) is a key commonly found on computer keyboards . It is primarily used to switch between the two text-entering ...

Inserts Wallpapers & Photos on the App Store on iTunes
Get Inserts Wallpapers & Photos on the App Store. See screenshots and ratings, and read customer reviews.

hud-dot-epa south lincoln insert - Flickr - Photo Sharing!
www.sustainablecommunities.gov/pdf/partnership_accomplish...

Lumia 640 XL - How to insert SIM and memory card - YouTube
Learn how to get started with your Lumia 640 XL or Lumia 640 XL Dual SIM. In this video you'll learn how to insert the SIM cards and the memory ...

Google Maps prankster inserts image of Android robot urinating on Apple logo
It seems even Google Maps can fall victim digital vandalism.

Dear [insert name], Qantas takes your complaint very seriously, honest
What's more annoying than being delayed nine hours on a long-haul flight between Sydney and Los Angeles, while stuck in a seat with a broken ...

Skype to insert advertising into calls
Skype to insert advertising into calls

ISIS inserts disturbing images into N.L. vote Twitter chatter
Note: The CBC does not necessarily endorse any of the views posted. By submitting your comments, you acknowledge that CBC has the right to reproduce, ...

Updates for Google Docs & Slides let you insert & quickly edit images on Android/iOS
Google is today rolling out updates to its Google Docs and Slides mobile apps bringing the ability to insert images directly from the app on ...

Gmail for iOS updated with ‘Insert from Drive’ and ‘Save to Drive’
Google has released an update to Gmail for iOS this afternoon that brings “Insert from Drive” and “Save to Drive” functionality to the iPhone ...

Resources last updated: 12/7/2015 3:09:57 AM