I'm trying to do a one-to-many insert in an ASP.Net web site that uses C# as the code-behind-the-solution.
The first insert into the main table is easy. First I set up the table to have a primary key that is auto-incremented. Then, I just do the insert like so...
SqlDataSource1.InsertCommand = "INSERT INTO [RequestTable] ([DateSubmitted], [ReferringPhysician]) VALUES ('11/11/12', 'Dr. Spock')";
and the primary key is automatically generated.
Next, I have a table that has as its first column the primary key from the first table, and then a specific value for the second.
My problem is - how do I get the automatically-generated primary key value from the first insert in order to make an insertion into the second table?
Thanks in advance,