Insert SQL to Parent and Child Tables
Insert SQL to Parent and Child Tables
am 12.04.2007 16:16:59 von PinkBishop
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
Re: Insert SQL to Parent and Child Tables
am 12.04.2007 16:50:14 von reb01501
PinkBishop wrote:
> 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.
--
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.
Re: Insert SQL to Parent and Child Tables
am 12.04.2007 17:07:41 von PinkBishop
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
On Thu, 12 Apr 2007 10:50:14 -0400, "Bob Barrows [MVP]"
wrote:
>PinkBishop wrote:
>> 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.
Re: Insert SQL to Parent and Child Tables
am 12.04.2007 17:25:25 von reb01501
PinkBishop wrote:
> 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.
--
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.
Re: Insert SQL to Parent and Child Tables
am 12.04.2007 17:28:49 von PinkBishop
Thanks
On Thu, 12 Apr 2007 11:25:25 -0400, "Bob Barrows [MVP]"
wrote:
>PinkBishop wrote:
>> 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.