Can anyone help me to access the array that is returned from the VB code below in my ASP Page -
Function GetAllCodes(iComp As Integer, sCat As String) As Variant
' ##PD iComp. The company
' ##PD sCat. The Code Category.
' ##RD A Variant. A two dimentional array. Array(0)(x) = ids. Array(1)(x) = Values _
Thus aCodes(0)(0) = M, aCodes(1)(0) = Male _
Null if none found
Dim cnn1 As ADODB.Connection
Dim rsCodes As ADODB.Recordset
Dim aCodeId() As String
Dim aCodeValue() As String
Dim cnt As Integer
Dim aBoth As Variant
Dim sql As String
On Error GoTo errorHandler
' Open connection.
Set cnn1 = New ADODB.Connection
cnn1.Open GetConnectionString()
' Open employee table.
Set rsCodes = New ADODB.Recordset
rsCodes.CursorType = adOpenKeyset
rsCodes.LockType = adLockOptimistic
sql = "SELECT CodeId, Value from Codes where CompanyId = " & _
iComp & " AND Category = '" & _
sCat & "';"
rsCodes.Open sql, cnn1, , , adCmdText
Do While rsCodes.EOF = False
ReDim Preserve aCodeId(cnt)
ReDim Preserve aCodeValue(cnt)
aCodeId(cnt) = rsCodes!CodeId
aCodeValue(cnt) = rsCodes!Value
cnt = cnt + 1
rsCodes.MoveNext
Loop
If cnt > 0 Then
ReDim aBoth(1)
aBoth(0) = aCodeId
aBoth(1) = aCodeValue
Else
aBoth = Null
End If
GetAllCodes = aBoth
' Disconnect the recordset
Set rsCodes = Nothing
Set cnn1 = Nothing
End Function [sig][/sig]
Function GetAllCodes(iComp As Integer, sCat As String) As Variant
' ##PD iComp. The company
' ##PD sCat. The Code Category.
' ##RD A Variant. A two dimentional array. Array(0)(x) = ids. Array(1)(x) = Values _
Thus aCodes(0)(0) = M, aCodes(1)(0) = Male _
Null if none found
Dim cnn1 As ADODB.Connection
Dim rsCodes As ADODB.Recordset
Dim aCodeId() As String
Dim aCodeValue() As String
Dim cnt As Integer
Dim aBoth As Variant
Dim sql As String
On Error GoTo errorHandler
' Open connection.
Set cnn1 = New ADODB.Connection
cnn1.Open GetConnectionString()
' Open employee table.
Set rsCodes = New ADODB.Recordset
rsCodes.CursorType = adOpenKeyset
rsCodes.LockType = adLockOptimistic
sql = "SELECT CodeId, Value from Codes where CompanyId = " & _
iComp & " AND Category = '" & _
sCat & "';"
rsCodes.Open sql, cnn1, , , adCmdText
Do While rsCodes.EOF = False
ReDim Preserve aCodeId(cnt)
ReDim Preserve aCodeValue(cnt)
aCodeId(cnt) = rsCodes!CodeId
aCodeValue(cnt) = rsCodes!Value
cnt = cnt + 1
rsCodes.MoveNext
Loop
If cnt > 0 Then
ReDim aBoth(1)
aBoth(0) = aCodeId
aBoth(1) = aCodeValue
Else
aBoth = Null
End If
GetAllCodes = aBoth
' Disconnect the recordset
Set rsCodes = Nothing
Set cnn1 = Nothing
End Function [sig][/sig]