Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ASP / Database Access / April 2007



Tip: Looking for answers? Try searching our database.

Insert SQL to Parent and Child Tables

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PinkBishop - 12 Apr 2007 15:16 GMT
Can somebody direct me on proper syntax of SQL statement to insert
into one table that has child table in a relational database?

I can get the insert to work for the Parent, but a record also needs
to be inserted into the Child.   Below is an example of my tables.  I
get Table 1 to insert no problem.  What I need is table 2 to populate
based on the catID from table 1 which is primarty key and selected
imgID from table 3.  Thanks for your help.

EX.

Table 1
 catID
 imgID
 venID

Table 2
 catID
 imgID

Table 3
 imgID
 imgName
Bob Barrows [MVP] - 12 Apr 2007 15:50 GMT
> Can somebody direct me on proper syntax of SQL statement to insert
> into one table that has child table in a relational database?

BAsically, do the insert into the parent table, get the ID of the new
record (http://www.aspfaq.com/show.asp?id=2174), and use that ID to do
the inserts into the child tables.

Signature

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

PinkBishop - 12 Apr 2007 16:07 GMT
Thanks for the source, but will this work in asp.net as well?

I aplogize if posting to the wrong group, but new to asp.net and
thought there would be similar solutions in this group.

I am trying to do this through Visual Studio 2005 Pro..

Thanks,

PB

>> Can somebody direct me on proper syntax of SQL statement to insert
>> into one table that has child table in a relational database?
>
>BAsically, do the insert into the parent table, get the ID of the new
>record (http://www.aspfaq.com/show.asp?id=2174), and use that ID to do
>the inserts into the child tables.
Bob Barrows [MVP] - 12 Apr 2007 16:25 GMT
> Thanks for the source, but will this work in asp.net as well?
Not the details, but the idea is the same. ISTM that datasets have some
builtin functionality to make this simpler but I've never used it.

For dotnet questions, you need to go to
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.

Signature

Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

PinkBishop - 12 Apr 2007 16:28 GMT
Thanks

>> Thanks for the source, but will this work in asp.net as well?
>Not the details, but the idea is the same. ISTM that datasets have some
[quoted text clipped - 4 lines]
>There are also forums at www.asp.net where you can find a lot of people
>to help you.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.