Move the line
Dim newOrdreRow As DataRow = Kalkyle1DataSet.Tables("Ordre").NewRow() so that it's inside the third iteration, just above the line
newOrdreRow("OrdreID") = MaxID (
this is for fixing the error message).
And add the line
Kalkyle1DataSet.AcceptChanges() just after the iteratation.
Also, if OrdreID is the unique identifier you need to increment it on every itereration. Not just once before you start to copy records.
So, change the line
newOrdreRow("OrdreID") = MaxID to
MaxID += 1
newOrdreRow("OrdreID") = MaxID
Reputation Points: 87
Solved Threads: 128
Practically a Master Poster
Offline 651 posts
since Jun 2006