Question update datatable to sql database with filtering

fredyciang

Member
Joined
Dec 28, 2011
Messages
6
Programming Experience
1-3
Hi there. im using vb.net winform.
i need help regarding this.
i want to update a datatable to sqlserver. but before that. i need to check by comparing it to another datatable(same structure but contain new data). i need to insert new data only.
Thank you
 
Your description is not specific enough. What EXACTLY is the relationship between the two DataTables. I'm assuming that you mean that you to insert records from the first DataTable that do not appear in the second DataTable, but what exactly constitutes a match? If both DataTables have the same primary key then you just loop through second table, get each ID, call Find for the first DataTable and, if a match is found, Remove the row. If there's some other relationship then we need to know what that is. Also, it would be useful to know how exactly each DataTable was populated, as that might have an impact on the detail.
 
sorry. this is the illustration :
datatable A and B have the same structure (with one PK) but different data.
i want to insert to data from datatable B which datatable A doesnt have.

i know i can loop and compare the PK. but the datarow is too much.
is there any other way to get the data without having to loop the datatable B?
 
Back
Top