【发布时间】:2014-07-03 19:50:04
【问题描述】:
只要我不在 sql 语句中使用“As Total”,以下代码就可以正常工作。任何列名都可以正常工作。
'Get the total number of trusses this type
sql2 = "SELECT max(sequencenumber) as Total from fitapieces fs WHERE fs.projectnumber = " & TempPieceInfo.ProjectNumber & " And fs.buildingtype = '" & TempPieceInfo.BuildingType & "' And " &
" fs.buildingnumber = '" & TempPieceInfo.BuildingNumber & "' And fs.buildinglevel = '" & TempPieceInfo.BLevel & "' And fs.batch = '" & TempPieceInfo.Batch & "' and fs.trussname = '" & TempPieceInfo.Trussname & "'"
myDataset2 = SelectFromDB(sql)
If Not myDataset2 Is Nothing Then
If myDataset2.Tables("CurData").Rows.Count > 0 Then
TempPieceInfo.TotalNumberofTrussesThisType = myDataset2.Tables("CurData").Rows(0).Item("Total").ToString.Trim
End If
End If
当我使用“作为总计”时,我收到“总计”不属于表“CurData”的错误。
在使用数据集时使用“As”子句有什么不同?
【问题讨论】:
-
应该将变量 'sql2' 改为 'sql' 吗?
-
您确定
SelectFromDB正在填充CurData表吗?