datatable filter issue
I've got two different tables in my database. One is Class and other one is LAREACT and both of them have a key field of MAIN FACILITY USED. In the following part of my code a DataTable will be generated based on the sum of the records on both tables. Based on the bellow code ACTIVITYLOOKUP datatable is having "MAIN FACILITY USED","Description","TypeName","Type","Id" columns. The issue happens when there is a row with the same MAIN FACILITY USED entity. The datatable will not show it (filter it?). Do you know where the problem lies? and how it will be fixed without any modification in database?
While oLArea.GetCurrent(oCursor)
oRow = DS.Tables("ActivityLookup").NewRow
oRow.Item("MainFacilityUsed") = oLArea.MAIN_FACILITY_USED
oRow.Item("Description") = oLArea.DESCRIPTION
oRow.Item("TypeName") = If(oLArea.TYPE = "G", "Group", "Single")
oRow.Item("Type") = oLArea.TYPE
oRow.Item("Id") = oRow.Item("Type") & "-" & oRow.Item("MainFacilityUsed")
DS.Tables("ActivityLookup").Rows.Add(oRow)
oCursor.MoveNext()
End While
If bIncludeClasses Then
Dim oClass As New CFastLookup
Dim d As Date = DateAdd(DateInterval.Year, 1, Today)
oCursor = oClass.ClassLookup(tCentreId, d)
While oClass.GetCurrent(oCursor)
DS.Tables("ActivityLookup").DefaultView.RowFilter = "[MainFacilityUsed]=" & EncodeToText(oClass.moGen.Item("MAIN FACILITY USED"))
If DS.Tables("ActivityLookup").DefaultView.Count = 0 Then
oRow = DS.Tables("ActivityLookup").NewRow
oRow.Item("MainFacilityUsed") = oClass.moGen.Item("MAIN FACILITY USED")
oRow.Item("Description") = oClass.moGen.Item("Description")
oRow.Item("TypeName") = "Class"
oRow.Item("Type") = "C"
oRow.Item("Id") = oRow.Item("Type") & "-" & oRow.Item("MainFacilityUsed")
DS.Tables("ActivityLookup").Rows.Add(oRow)
End If
oCursor.MoveNext()
End Wh开发者_StackOverflowile
End If
DS.Tables("ActivityLookup").DefaultView.RowFilter = ""
DS.AcceptChanges()
Try specifying UNION ALL in your SQL.
精彩评论