[英]How to sum a column from a running total data table in VB.NET?
我目前正在處理一個項目,遇到了一個錯誤: Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier
。 我在 BusinessAnalytics 數據表中有一個名為“Total#”的列。 我想將列匯總在一起,以便我可以使用它來計算成員百分比和非成員百分比。 我怎樣才能解決這個問題?
我的帶有運行總計的數據表的代碼
Dim decTotalNumber As Decimal
Dim decPercentSales As Decimal
Dim intRow As Integer
If chkRewards.Checked = True Then
intRow = 1 'member
Else
intRow = 0 'nonmember
End If
With BusinessAnalytics.Rows(intRow)
.Item("Total#") += 1
decTotalNumber = BusinessAnalytics.Compute("SUM(Total#)", Nothing)
decPercentSales = Convert.ToDecimal(.Item("Total#")) / decTotalNumber
.Item("%Total") = decPercentSales.ToString("P1")
End With
GridView3.DataSource = BusinessAnalytics
GridView3.DataBind()
您的列名稱包含非字母數字字符,因此應將其括在方括號或“`”(重音符號)引號中。
所以你的陳述應該是:
decTotalNumber = BusinessAnalytics.Compute("SUM([Total#])", Nothing)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.