F
Frank
Hello All,
I am working on a vb.net app where I need to compare to 2 datatables
and determine if a string exists in one or both. The first dt is
filled from the db. A form is loaded and the appropriate items in a
checkedlist box are selected based on the dt. So far, no problem. Then
user can then edit the values in the checkedlist box and choose to
save changes. When they save changes, I throw the new values of the
checked items from the checklistbox into a new dt and compare the two.
Posed a similar question a couple of weeks ago, and was going to try a
comparison based on a datarow but was stymied because the 2 dt's don't
match. Any help will be greatly apprecitated!
Here is some code:
For i = 0 To myDSOrig.Tables(0).Rows.Count - 1
For z = 0 To dsChanged.Tables(0).Rows.Count - 1
If myDSOrig.Tables(0).Rows(i).Item(5).ToString =
dsChanged.Tables(0).Rows(z).Item(5).ToString Then
Exit For
Else
lblChg = New Label
lblChg.Text = myDSOrig.Tables(0).Rows(i)(5)
...
End If
Next z
Next i
This little routine works fine if more than 1 string does not match.
However, if only 1 string doesn't match, then it fails by capturing
the unequal string twice and one string that does match! ie:
TIA,
Dan
I am working on a vb.net app where I need to compare to 2 datatables
and determine if a string exists in one or both. The first dt is
filled from the db. A form is loaded and the appropriate items in a
checkedlist box are selected based on the dt. So far, no problem. Then
user can then edit the values in the checkedlist box and choose to
save changes. When they save changes, I throw the new values of the
checked items from the checklistbox into a new dt and compare the two.
Posed a similar question a couple of weeks ago, and was going to try a
comparison based on a datarow but was stymied because the 2 dt's don't
match. Any help will be greatly apprecitated!
Here is some code:
For i = 0 To myDSOrig.Tables(0).Rows.Count - 1
For z = 0 To dsChanged.Tables(0).Rows.Count - 1
If myDSOrig.Tables(0).Rows(i).Item(5).ToString =
dsChanged.Tables(0).Rows(z).Item(5).ToString Then
Exit For
Else
lblChg = New Label
lblChg.Text = myDSOrig.Tables(0).Rows(i)(5)
...
End If
Next z
Next i
This little routine works fine if more than 1 string does not match.
However, if only 1 string doesn't match, then it fails by capturing
the unequal string twice and one string that does match! ie:
TIA,
Dan