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