1、数量和金额是表达式列,sql是无法使用表达式列的2、尽量保持数据库表的名称,或者干脆把数据库表名称改正确, 不要乱改名,容易出错。因为sql是使用数据库的表名的
3、参考:
Dim cmd As New SQLCommand
cmd.ConnectionName = "移动示例" '记得设置数据源名称
cmd.CommandText = "Select Count(*) From {订单}" & iif(Filter > "", " Where " & Filter, "")
Dim Count As Integer = cmd.ExecuteScalar() '获取总的行数
Dim Pages As Integer = Math.Ceiling(Count/PageRows) '计算出总页数
cmd.CommandText = "Select Top " & pagerows & " *,(数量*单价) As 金额 from (Select [_identify] as 订单编号,日期,客户,(Select sum(数量) from 订单 where 订单编号={订单}.订单编号) As 数量,单价 From {产品}) A where "
cmd.CommandText &= iif(page=0, "1=1" , "[订单编号] not In (Select top " & pagerows * page & " [_identify] from {产品} order by [_identify]) order by [订单编号]")
Dim dt As DataTable = cmd.ExecuteReader