举个例子:
select sum(" + adoRecordset.Fields(ColIndex).Name + ") from ad
然后怎样才能把这个查询结果赋值给一个变量???
谢谢!!!
------解决方案--------------------------------------------------------
Dim sql As String
Dim aa As Integer
MsgBox adoRecordset.Fields(ColIndex).Name
sql = "select sum(" + adoRecordset.Fields(ColIndex).Name + ") as aa from ad "
' adoConnection.Execute sql
'Set adoRecordset = adoConnection.Execute("select sum(" + adoRecordset.Fields(ColIndex).Name + ")as aa from ad")
' MsgBox aa
Set adoRecordset = Nothing
adoRecordset.Open sql, adoConnection, 1, 3
MsgBox "合计:" & adoRecordset.Fields.Item(0).Value
------解决方案--------------------------------------------------------
直接赋值就行
- VBScript code
dim result as intsql = "select sum(" + adoRecordset.Fields(ColIndex).Name + ") as counter from ad" rs.open sql, myconn, 3,3,1 '假设rs和myconn已经定义好和初始化好。result = rs("counter") '在这里赋值。