1
我試圖從初始SQL查詢中使用resultSet中的記錄作爲循環控制,並將值填充到後續的SQL語句中。後面的SQL語句resultSet將被用來填充一個HTML表格。無效For循環控制變量,嵌套ResultSet SQL
在試圖做到這一點,我打這個問題
微軟VBScript編譯錯誤 '800a0410'
無效 'for' 循環控制變量
/ps/testcli.asp,行83
對於每個objFieldValue在RS.Fields
------------------ -----^
我最初的想法是,它無法辨別客戶RS和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腳本中使用VBScript
謝謝。這解決了編譯問題。 – HexEDSyght