I'm sure that Tore's method is much better, but this is how I do data
access.  I generally pass in x number of arrays by ref then in the vb
loop through the recordset and fill these arrays.  Then your asp has
multiple arrays all with the same number of elements.

Dim obj
Dim strVar1
Dim strVar2
Dim strErrorMsg
Dim lngCounter
ReDim strVar3(0)
ReDim strVar4(0)


set obj = Server.CreateObject ("MyDllName.MyClassName")
lngResult = obj.MyFunctionName (strVar1, strVar2, arrVar3, arrVar4,
strResults, strErrorMsg)
set obj = nothing

If lngResult <= 0 Then
        Response.Write strErrorMsg
Else
        For lngCounter = 0 to ubound(arrVar3)
                'Do Something Here
                Response.Write arrVar3(lngCounter) & " " &
arrVar4(lngCounter) & "<br>"
        Next
End If


Here is a basic VB function that is guaranteed not to work.  Make sure
you do some error handling.  This function would be in a VB DLL named
MhDllName and inside a class named MyClassName.

Public Function MyFunctionName(ByVal strVar1 As String, ByVal strVar2 As
String, ByRef arrVar3, ByRef arrVar4, ByRef strErrorMsg) As Long
'Open DB and recordset here.

    Dim i As Integer
    Do While Not adoRS.EOF
        ReDim Preserve arrVar3(i)
        arrVar3(i) = "" & adoRS("ColumnName").Value
        
        ReDim Preserve arrVar4(i)
        arrVar4(i) = "" & adoRS("OtherColumnName").Value
        
        i = i + 1
        adoRS.MoveNext
    Loop

    MyFunctionName = i
    
EX:
'Clean up db conn and rs here
Exit Function

ER:
'Handle your errors somehow.
   MyFunctionName = -1
   strErrorMsg = strErrorMsg & "VB error: " & Err & ", " & Error
   GoTo EX

End Function


Andrew

-----Original Message-----
From: Tsiris Alexandros [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 17, 2002 6:43 AM
To: ActiveServerPages
Subject: passing variables to a COM object.


I have some variables that I need to pass to  COM that will then access
a databse based on those variables and return some data. How do I pass
variables from an asp page to a COM?

Is it similar to passing variables (i.e. querystring) from one ASP page
to another?

TIA,

Alexander

---
You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED] To unsubscribe send a blank email to
%%email.unsub%%

---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to