我想在vbscript中获取一个二维数组的表(我使用asp访问mdb),无论如何,我试图让它像这样:
'Levels'
Dim one : one = Array()
Dim two : two = Array()
Dim three : three = Array()
Dim four : four = Array()
Dim five : five = Array()
Dim level
recordset.open sql, connection
If recordset.RecordCount <> 0 Then
For Each record In recordset
level = record("Level")
Select Case level
Case 1
Case 2
Case 3
Case 4
Case 5
End Select
Next
End If
但似乎它不起作用,我也不确定二维变量声明是否是正确的做法。
有人可以启发我吗? 提前谢谢。
答案 0 :(得分:4)
为什么不使用内置的GetRows()方法。这将获取您的记录集并将其放入二维数组中。以下是来自w3schools.com的示例代码,它很好地说明了这种方法:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("northwind.mdb"))
set rs = Server.CreateObject("ADODB.recordset")
rs.Open "Select * from Customers", conn
'The first number indicates how many records to copy
'The second number indicates what recordnumber to start on
p=rs.GetRows(2,0)
rs.close
conn.close
'This example returns the value of the first
'column in the first two records
response.write(p(0,0))
response.write("<br>")
response.write(p(0,1))
'This example returns the value of the first
'three columns in the first record
response.write(p(0,0))
response.write("<br>")
response.write(p(1,0))
response.write("<br>")
response.write(p(2,0))
%>