我正在尝试使用来自初始 SQL 查询的结果集中的记录作为循环控制,并将值填充到后续 SQL 语句中。然后,后面的 SQL 语句 resultSet 将用于填充 HTML 表格。
在尝试实现这一目标时,我遇到了这个问题
Microsoft VBScript 编译错误“800a0410”
无效的“for”循环控制变量
/ps/testcli.asp,第 83 行
对于 RS.Fields 中的每个 objFieldValue
----------------------^
我最初的想法是它无法区分 clientRS 和 RS,但似乎并非如此。下面的行从 39 - 97 开始
SQLDel = "DELETE * FROM ClientModuleList"
SQLDel2 = "DELETE FROM PSS.dbo.TestCli"
'------
SQLGetClientsV1MVSOld = "SELECT ClientID FROM PSS.dbo.CLIENTS WHERE CardpacVersion='Cardlink 1.0' AND OS='MVS'AND Base='Old'AND Active='1'"
SQLGetClientsV1MVSNew = "SELECT ClientID FROM CLIENTS WHERE CardpacVersion='Cardlink 1.0' , OS='MVS', Base='New', Active='1'"
SQLGetClientsV1AS4Old = "SELECT ClientID FROM CLIENTS WHERE CardpacVersion='Cardlink 1.0' , OS='AS4', Base='Old', Active='1'"
SQLGetClientsV2MVSOld = "SELECT ClientID FROM CLIENTS WHERE CardpacVersion='Cardlink 2.0' , OS='MVS', Base='Old', Active='1'"
'------
SQLGetModules01 = "SELECT Patchlib FROM "
SQLGetModules02 = " WHERE Type='B' AND Required='1'"
'-- Connection --
Set connDBO = Server.CreateObject("ADODB.Connection")
'-- ResultSets --
Set clientRS = Server.CreateObject("ADODB.RecordSet")
Set RS = Server.CreateObject("ADODB.RecordSet")
If Request.Form("submit") <> "" Then
'--Delete All Existing Rows --S001--
connDBO.open cString
connDBO.execute(SQLDel2)
connDBO.close
'--Delete All Existing Rows --E001--
'--Get all Clients which satisfy (Cardlink 1.0, MVS, Old, Active) into clientsRS --S002--
clientRS.Open SQLGetClientsV1MVSOld, cString
While NOT clientRS.EOF
For Each objFieldValue in clientRS.Fields
SQLGetModuleFull = "" & SQLGetModule01 & objFieldValue.Value & SQLGetModule02 & ""
RS.Open SQLGetModuleFull, cString
Response.Write("<table border='1'>" )
Response.Write("<tr>" )
For Each objFieldName in RS.Fields
Response.Write("<th>" & objFieldName.Name & "</th>" )
Next
Response.Write("</tr>" )
If NOT RS.EOF Then
While NOT RS.EOF
Response.Write("<tr>" )
For Each objFieldValue in RS.Fields
Response.Write("<td>" & objFieldValue.Value & "</td>" )
Next
Response.Write("</tr>" )
RS.MoveNext
WEnd
Response.Write("</table>" )
End If
Next
WEnd
RS.Close
clientRS.Close
End If
关于为什么会发生这种情况的任何提示?我对 ASP Classic 中使用的 VBScript 很陌生