I want to see if
IDfrom datatabledtOriginalAvailableexists as anIDin datatabledtCalculateCurrent.If the
IDdoes not exist in datatabledtCalculateCurrent, then I want to add a row in datatabledtCalculateCurrentwith thatID.
My attempt below does not work. How can I accomplish this?
For Each dr As DataRow In dtCalculateCurrent.Rows
Dim ma = Convert.ToInt32(dr("MaxAccount"))
Dim cn = Convert.ToInt32(dr("ActiveServiceCount"))
Dim calc = ma - cn
dr("CurrentNumber") = calc
'if service not in calculated because of 0 accounts, add as row in calculated
For Each origRow In dtOriginalAvailable.Rows
Dim findService As DataRow() = dtOriginalAvailable.[Select]("ID = '" & dr("ID") & "'")
If findService.Length = 0 Then
Dim R As DataRow = dtCalculateCurrent.NewRow
R("ID") = origRow("ID")
R("MaxAccount") = origRow("MaxAccount")
R("ActiveServiceCount") = 0
R("CurrentNumber") = 0
dtCalculateCurrent.Rows.Add(R)
dtCalculateCurrent.AcceptChanges()
End If
Next
Next