Select Case e.DataCol.Name
Case "收入","支出"
For Each dr As DataRow In e.DataTable.Select("[_SortKey] >= " & e.DataRow("_SortKey"))
Dim Val1 As Double = e.DataTable.Compute("Sum(收入)","[_SortKey] <= " & dr("_SortKey"))
Dim Val2 As Double = e.DataTable.Compute("Sum(支出)","[_SortKey] <= " & dr("_SortKey"))
dr("余额") = Val1 - Val2
Next
End Select
这是流水帐帮助中一段代码,如果数据源为外部数据源,而且加载时只部分加载数据,用以上代码,那么"余额"就只根据加载的数据来计算,而无法准确反应"余额".用Sql语句能否实现准确计算"余额"?能否向后台数据中写入未加载行的"余额"?