PDA

Click to See Complete Forum and Search --> : VBscript arrays


turfbult
Oct 12th, 2000, 04:51 AM
Can one create an array with vbscript and if so, how??

What I want to do is select a field from a table and populate the array with the result of all the records which was returned, close the connection and recordset and then later in my HTML populate a dropdown menu with the results in the array.

This way I save on open connections/recordsets etc.

Any help??

monte96
Oct 12th, 2000, 10:05 AM
Dim arrMyArray
Dim strSQL
Dim cn
Dim rs

Set cn = Server.CreateObject("ADODB.Connection")
cnCn.ConnectionString = "Provider=SQLOLEDB;Server=" & SVR & ";Database=" & DB & ";UID=" & USER & ";Pwd=" & PWD & ";"
cnConn.Open
strSQL = "Select * from Table"
Set rs = cn.Execute strSQL
arrMyArray = rs.GetRows
rs.Close
cn.Close
Set rs = Nothing
Set cn = Nothing



This creates a two dimensional array:
arrMyArray(columns, rows)