
Empty Arrary when VBScript calls VB COM object.
I am writing
VBScript for an ASP which calls a COM object I've written
in VB. The function on the COM object has multiple recordsets returned
from an ADO call to the database. Data if pulled from the recordsets
and is placed into an array filled with 'n' number of 2-dimensional
arrays.
I created a form in VB for testing and was able to call the function on
the COM object successfully. It returned the array full of data.
However, when I tried to call this function from VBScript it didnt
return anything. Are VB and VBScript's array objects such different
animals that they cannot communicate directly?
I tried rewriting the COM object function as a sub, passing a byref
variant parameter, but to no avail.
I'm unsure if I'm writing this incorrectly or if there is a bug in the
way VB and VBScript's arrays interact. Any suggestions?
Below you will find the COM object function in VB...below it you'll
find the VBScript:
Thanks in advance for your help,
Kelly McCullough
___________________________________
Public Function GetCodes() As Variant
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim params As ADODB.Parameters
Dim param As ADODB.Parameter
Dim j As Integer
Dim i As Integer
Dim intCount As Integer
Dim arr()
Dim intMvarCodesUbound As Integer
'<Database calling code removed>
Set rs = cmd.Execute
j = 0
Do While rs.State <> adStateClosed
intCount = rs.RecordCount - 1
ReDim arr(intCount, 3)
For i = 0 To intCount
arr(i, 0) = rs(CategoryID)
arr(i, 1) = rs(CodeID)
arr(i, 2) = rs(CodeValue)
arr(i, 3) = rs(Order)
rs.MoveNext
Next i
mvarCodes(j) = arr
Set rs = GetNextRecordSet(rs)
j = j + 1
Loop
GetCodes = mvarCodes
end function
Private Function GetNextRecordSet(ByVal rs As Recordset)
Set GetNextRecordSet = rs.NextRecordset
End Function
--------------------------------------
VBSCRIPT
--------------------------------------
Dim arr
Dim objCode
Set objCode = Server.CreateObject("SMSBusObjs.cCode")
arr = objCode.GetCodes
Sent via Deja.com
http://www.*-*-*.com/