Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 February 6th, 2011, 09:18 AM
Registered User
 
Join Date: Feb 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default ADO design question

Hey guys,

I've got 2 tables...

Computer

Motherboard

now computer has a FK constraint from Motherboards PK so I can no longer do a simple insert without having the motherboard present. That all works correctly.

Now in my ADO I've got an insert statement on Computer which calls a stored proc. Should I pass all my variables to the Stored proc? and call internally other Stored procs from the main one?

Or should ADO be able to handle mapping? I'm confused how I can tell my ADO to insert into Motherboard first and then insert into Computer.
 
Old February 13th, 2012, 05:53 AM
Registered User
 
Join Date: May 2011
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Default

you can pass all values to same procedure and using the values for motherboard table first insert the record and declare a variable to store the identity of the motherboard table that will be used in the computer's table

e.g

insert into motherboard (col1, col2, col3, ......)
values (@Para1, @Para2, @Para3,....)

Declare @ID
SET @ID = @@SCOPE_IDENTITY

insert into computer (col1, col2, col3, .... , col_fk_motherboard)
values (@Para4, @Para5, @Para6, .... , @ID)


Regards,
Akaas Developer
http://www.questions-interviews.com/...hnologies.aspx





Similar Threads
Thread Thread Starter Forum Replies Last Post
Question OF Design SP2010Dude BOOK: Beginning ASP.NET 4 : in C# and VB 6 September 17th, 2010 01:59 PM
design question androoo ADO.NET 1 November 13th, 2004 09:41 AM
Design Question flyin General .NET 4 July 21st, 2004 03:59 PM
Design question? qadeer05 SQL Server 2000 4 May 3rd, 2004 10:17 AM





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