navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Insert to Parent and Child Table SQL Statement

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Insert to Parent and Child Table SQL Statement
Page: [1]
 
truwebs

 

Posts: 80
Joined: 7/10/2006
Status: offline

 
Insert to Parent and Child Table SQL Statement - 4/12/2007 10:23:33   
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
Spooky

 

Posts: 26606
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Insert to Parent and Child Table SQL Statement - 4/13/2007 15:13:48   
Normally youll add them when the first record is inserted?
After an insert into table1, youll need to extract the ID of the new record and then perform an insert into table 2 using that new ID

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to truwebs)
truwebs

 

Posts: 80
Joined: 7/10/2006
Status: offline

 
RE: Insert to Parent and Child Table SQL Statement - 4/13/2007 17:34:11   
I agree with you but, how do I do this?

All I have found is that I need to do a Select @@ Identity after the insert into table 1.

I am trying to do this with the .net framework using VB and an Access database.

Just don't know how to proceed with use of the Select@@Identity.

TRU

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Insert to Parent and Child Table SQL Statement
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts