Hello,
I am trying to perform an insert with a select embedded within the insert....with little success. I am making 2 inserts, the first would be the parent table and the second, the child. I'm attempting to get the customerid from the parent table and insert it into the child table as the foreign key. I was hoping someone could either right my wrong or explain what needs to be done. Thanks in advance!
I am trying to perform an insert with a select embedded within the insert....with little success. I am making 2 inserts, the first would be the parent table and the second, the child. I'm attempting to get the customerid from the parent table and insert it into the child table as the foreign key. I was hoping someone could either right my wrong or explain what needs to be done. Thanks in advance!
Code:
Dim strSQL As String = "Insert into Customers(FirstName, LastName ) Values('" & fNameText.Text & "','" & lNameText.Text & "');"
----Second Insert
strSQL = "Insert into Jobs(CustomerID, Days, SpringRaking," & _
"LawnCutting, FallLeaves, SnowPlowing, Labor, Materials, Misc) Values(Select Top 1 Customers.CustomerID from Customers order by Customers.CustomerID desc;,'" & fNameText.Text & _
"','" & lNameText.Text & "','" & ddDays.SelectedValue & "'," & sprngRak & "," & lwnCttng & "," & fallLvs & _
"," & snwPlwng & "," & laborText.Text & "," & MaterialsCost.Text & "," & misc & ");"