database - How to get recordset into bidimensional array in vbscript? -
i want table bidimensional array in vbscript (i'm using asp access mdb), anyway, trying make this:
'levels' dim 1 : 1 = array() dim 2 : 2 = array() dim 3 : 3 = array() dim 4 : 4 = array() dim 5 : 5 = array() dim level recordset.open sql, connection if recordset.recordcount <> 0 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
but seems doesn't work, i'm not sure if bidimensional variable declaration right way of doing it.
can 1 enlighten me? in advance.
why not use built-in getrows() method instead. takes recordset , puts 2 dimensional array. here's sample code w3schools.com illustrates method well:
<% 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 * customers", conn 'the first number indicates how many records copy 'the second number indicates recordnumber start on p=rs.getrows(2,0) rs.close conn.close 'this example returns value of first 'column in first 2 records response.write(p(0,0)) response.write("<br>") response.write(p(0,1)) 'this example returns value of first 'three columns in first record response.write(p(0,0)) response.write("<br>") response.write(p(1,0)) response.write("<br>") response.write(p(2,0)) %>
Comments
Post a Comment