sae*_* ek -1 html vbscript asp-classic
我有一个简单VBScript的从数据库获取数据并迭代它们并生成一个表.在此迭代期间,我想捕获一些数据(特定列的值)并将它们保存在变量中供以后使用.但是每当我的代码到达那个if语句时,它就不再循环了.
Dim lats
Dim longs
Set lats = CreateObject("System.Collections.ArrayList")
Set longs = CreateObject("System.Collections.ArrayList")
%>
<table>
<tr><th>Office</th><th>Address</th><th>Comune</th><th>Province</th><th>Lat</th><th>Long</th><th>2G</th><th>3G</th><th>4G</th></tr>
<%do until rs.EOF
response.write("<tr>")
for each x in rs.Fields
response.write("<td>" & response.write(x.value) &"</td>")
'IF the below statement equals true, the loop doesn't perform anymore
If x.name = "SITE_LAT_N" Then
lats.Add x.value
ElseIf x.name = "SITE_LON_E" Then
longs(indx) = x.value
End If
next
rs.MoveNext
response.write("</tr>")
loop
rs.close
conn.close
%>
</table>
Run Code Online (Sandbox Code Playgroud)
longs(indx) = x.value
Run Code Online (Sandbox Code Playgroud)
看起来很腥.证据:
>> set al = CreateObject("System.Collections.ArrayList")
>> al.Add "works"
>> WScript.echo al(0)
>> al(1) = "doesn't work"
>>
works
Error Number: -2146233086
Error Description: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein.
Parametername: index
Run Code Online (Sandbox Code Playgroud)
另外:它indx来自哪里?你不能用
longs.add x.value
Run Code Online (Sandbox Code Playgroud)