Take a look at the pseudo code provided. You have several options,
including setting property values (which you would save in private variables
in the component) or passing as parameters to a procedure. For example, you
could have something like (consider it pseudo code):
(In the code that uses the component:)
Set rsX = objMyComponent.GetMyRecordSet(x, y)
(In the Component:)
Public Function GetMyRecordSet(ByVal x as String, ByVal y as Long) as
ADODB.Recordset
Dim cn as ADODB.Connection
Dim rs as ADODB.Recordset
Dim sSQL as string
...
cn.ConnectionString = "..."
'Use Client Side Cursor:
cn.CursorLocation = adUseClient
cn.Open
...
sSQL = "Select <list> from <table> Where Col1 = '" & x & "' and Col2
= " & y
rs.Open sSQL, cn, adOpenForwardOnly, adLockReadOnly
'Disconnect the recordset before returning it:
Set rs.ActiveConnection = Nothing
ExitHandler:
Set GetMyRecordset = rs
'Cleanup code goes here:
'Destroy redundant reference
Set rs = Nothing
'Close and destroy connection object:
If Not cn is Nothing Then
If cn.State = adStateOpen Then
cn.Close
End If
Set cn = Nothing
End If
Exit Function
ErrHandler:
...
HTH,
Tore.
-----Original Message-----
From: Tsiris Alexandros [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 17, 2002 10:15 AM
To: ActiveServerPages
Subject: RE: passing variables to a COM object.
> -----Original Message-----
> From: Bostrup, Tore [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 4:49 PM
> To: ActiveServerPages
> Subject: RE: passing variables to a COM object.
SNIP
> Creating a COM component in VB is extremely simple - just
> specify ActiveX
> DLL (or ActiveX Exe) for the new project type. Name the
> project something
> meaningful.
SNIP
Thank you very very much!
That was a superb answer.
I am reading VB COM (the book by Wrox), but I have a deadline to create a
component that basically does a search on a databse for a name that I need
to pass from my ASP page to it, and then return the data from the database.
So far in the book (it seems like an excellent book), it has not mentioned
this, your answer is very helpful!
P.S.
Ok, I see now how to call the component, but how to I pass 2 variables to it
so it can use them to do the search, and how do I return the data back to
the ASp page?
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]