PDA

Click to See Complete Forum and Search --> : Passing objects in Add method for Collection object from ASP page.


chris.net
Mar 18th, 2005, 11:48 AM
To begin, I apologize if this is a silly and trivial question, but it is driving me nuts.

I have a business object in VB6 called ResultItem that will contain properties for items returned in a search. Sample properties include ItemID (str), Description (str), Price (str).

I also have a collection object called Results that is a collection of ResultItems. I customized the Add method to be a subroutine and the parameters are objNewMember as ResultItem and Optional sKey as string = "".

This all, of course, works beautifully in a VB6 exe. But when I try to add a ResultItem to my Results collection via ASP I get a type mismatch error.

In my ASP script, I create a ResultItem object and load it up fine. Then I create my Results collection object and try to add the ResultItem object to the collection. This is when my type mismatch error occurs.

I am sure the issue is because we go from ASP, a typeless environment, to COM, a strongly typed environment. But I am sure there is a way to do this.

I already tried changing my Add method from:
Public Sub Add(objNewMember as ResultItem, Optional sKey as string = "")
To:
Public Sub Add(objNewMember as Variant, Optional sKey as string = "")

But I get the same thing; type mismatch.

I also tried this:
Public Sub Add(sItemID as string, sDescription as string, Optional sKey as string = "")
and created the ResultItem in my Add method. Now this worked, but the problem with this is I will have many properties in my ResultItem object, and I dont really want to have an Add method with 20 required parameters.

I would really appreciate any help on how to pass objects in COM methods from an ASP environment.

Thanks,
Chris

chris.net
Mar 18th, 2005, 05:01 PM
Well, I figured this out. I guess I did not unregister my older version of the COM or something, because I was able to pass in the ResultItem object as a variant after all.

Sorry for the question.