Albee_J
asked on
VB.net insert multiple records into table on insert based on Order Number
I have a table Order_No with Order_No (Auto Increment) and Date Ordered
I also have another table Order with ID, Order_No (Which needs to be populated of the next available number from the Order_No table)
Then I also need to know how to loop through on insert for my Orders table based on ProductID. Each Product has unique values and all items will be tied together by Order_No. I have done simple inserts into a table before, but never one like this...
help?
I also have another table Order with ID, Order_No (Which needs to be populated of the next available number from the Order_No table)
Then I also need to know how to loop through on insert for my Orders table based on ProductID. Each Product has unique values and all items will be tied together by Order_No. I have done simple inserts into a table before, but never one like this...
help?
Try
Dim insertOrder As New Data.SqlClient.SqlCommand("INSERT INTO Orders(Order_No,AssociationID,Customer_ID,ProductID,Options,Rate,RateOvveride) VALUES (@Order_No,@AssociationID,@Customer_ID,@ProductID,@Options,@Rate,@RateOvveride); SELECT SCOPE_IDENTITY();", myConnection)
insertOrder.Parameters.AddWithValue("@AssociationID", ddlAssociation.SelectedValue)
insertOrder.Parameters.AddWithValue("@Customer_ID", ddlExhibitor.SelectedValue)
insertOrder.Parameters.AddWithValue("@ProductID", txtDirProdID.Text)
insertOrder.Parameters.AddWithValue("@Options", ddlDirSize.SelectedValue)
myConnection.Open()
insertOrder.ExecuteNonQuery()
myConnection.Close()
Catch ex As Exception
lblConfirmation.Text = "Error saving: " & ex.Message.ToString
End Try
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.