[英]How to sum a column from a running total data table in VB.NET?
I am currently working on a project and am running into an error that says: Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier
.我目前正在处理一个项目,遇到了一个错误:
Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier
。 I have a column named "Total#" in a BusinessAnalytics data table.我在 BusinessAnalytics 数据表中有一个名为“Total#”的列。 I want to sum the column together so that I can use it to calculate a percentage of members and percentage of nonmembers.
我想将列汇总在一起,以便我可以使用它来计算成员百分比和非成员百分比。 How can I fix this?
我怎样才能解决这个问题?
My code for a data table with running totals我的带有运行总计的数据表的代码
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()
Your column name contains non-alphanumeric characters, so it should be wrapped in square brackets or "`" (grave accent) quotes.您的列名称包含非字母数字字符,因此应将其括在方括号或“`”(重音符号)引号中。
So your statement should be:所以你的陈述应该是:
decTotalNumber = BusinessAnalytics.Compute("SUM([Total#])", Nothing)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.