I am trying to create a new row using DataRow.Copy to copy the data from an existing row.
However after updating dependencies, I am experiencing the error below:
The use case is that I am checking if a student is below 18 years of age.
If this condition is met, then I lookup their guardian in another datatable and make a copy of the student’s row, replace their personal identification number with the one from their guardian, and inject this row into the original datatable.
The datatable with guardians contains 25+ columns that I dont need.
I simply need a new line in the students datatable, with the excact same values as the student has, and then simply replace a single value in a single column.
Yes I do
But as stated initially I need a copy of an existing row.
In the example below, the rows 2,3 and 6 represent rows injected with same values, but different PIN (for guardians).
As an example:
Student Name
Student Age
Student Address
City
Student PIN
John Doe
17
Test Road 1
Detroit
11223344
John Doe
17
Test Road 1
Detroit
11111111
John Doe
17
Test Road 1
Detroit
22222222
Emily Johnson
18
Test Boulevard 7
Kansas
12341234
Steward Anderson
15
Test Drive 19
New York
12121212
Steward Anderson
15
Test Drive 19
New York
44448888
I need to “letter braid” (dont know if thats the right word) in Microsoft Word afterwards.
We find reciepients based on PIN, so in the use case shown, the guardians would recieve the excact same letter as the students, as the values are the same.
Only difference is the PIN which has changed (and which marks the reciever).
A system that is used in the process afterwards needs 1 column for PIN to succesfully register the recipients and send to these people’s digital mailbox (all danish citizens have these).
And for the letters to contain the excact same info, the rest of the columns should just contain the same info as the student at hand.
I know how to lookup the datatable with guardians to find the correct one(s) (PIN is key here), but that is not the problem here.
The excact case here, is that I need to copy a row to 1-4 (depending on number of guardians) others, and just replace a single value in this row (containing 20+ other information).
Wouldn’t this simply copy the last row of the datatable?
I am iterating anywhere between a couple to several hundred rows.
Just as an example, it might be that I need 2 copies of row 73, 1 copy of row 103 and 3 copies of row 105.
No, this will make a copy of the CurrentRow and put the copy at the end of dt_DT1. If you need more than one copy, just repeat the sequence (add data row and retrieve).
Yes you’ll get a copy of the Student row for each Guardian, without actually copying the row. For example, if a Student has 5 Guardians, there will be 5 rows for that Student.
Maybe, if you could please upload anonymised sample data (Spreadsheet for Students and Guardians tables), I can make a workflow for you.