0
我在我的數據庫中有兩個不同的表。一個是Class,另一個是LAREACT,他們都有一個關鍵字段MAIN FACILITY USED。在我的代碼的以下部分中,將根據兩個表上的記錄總和生成一個DataTable。 基於以下代碼段,ACTIVITYLOOKUP數據表具有「主要設施已使用」,「描述」,「類型名稱」,「類型」,「標識」列。當存在與主MAIN FACILITY USED實體相同的行時,會發生該問題。數據表不會顯示它(過濾它?)。你知道問題出在哪裏嗎?以及如何在不對數據庫進行任何修改的情況下修復它?datatable filter issue
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 While
End If
DS.Tables("ActivityLookup").DefaultView.RowFilter = ""
DS.AcceptChanges()
你能夠顯示你用來填充數據集的SQL嗎? – Batuta 2011-03-07 22:38:48