Returning data from VC++ ASP component


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Returning data from VC++ ASP component

  1. #1
    Zohar Nissare-Houssen Guest

    Returning data from VC++ ASP component


    Hello,

    I have to write an ASP Component in VC++ who returns multiple variables.

    What is the easiest way to return for example 3 variables from the
    VC++ component to an ASP page written in VBScript ?

    - Can I do it using OUT parameters in the methods ; If so, how can I do it
    in my C++ method using OLE
    Automation ? And how can I code it in my ASP page using VBScript ?

    - If not, what is the easiest way to return these parameters ? Where can
    I find an easy sample of it ?


    Any help would be much appreciated.

    Thank you very much

    Zohar Nissare-Houssen
    TravelNet Technologies

    Share on Google+

  2. #2
    Scott Mitchell Guest

    Re: Returning data from VC++ ASP component


    Hello Zohar. I have very little experience with creating COM components via
    VC++. I've only done this once just to see if I could! :-) You can read
    about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml

    I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp

    Ask your questions there and you'll get great responses from seasoned pros...

    Happy Programming!

    Scott Mitchell
    mitchell@4guysfromrolla.com
    http://www.4GuysFromRolla.com
    http://www.ASPMessageBoard.com
    http://www.ASPFAQs.com

    * When you think ASP, think 4GuysFromRolla.com!

    "Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
    >
    >Hello,
    >
    >I have to write an ASP Component in VC++ who returns multiple variables.
    >
    >What is the easiest way to return for example 3 variables from the
    >VC++ component to an ASP page written in VBScript ?
    >
    >- Can I do it using OUT parameters in the methods ; If so, how can I do

    it
    >in my C++ method using OLE
    >Automation ? And how can I code it in my ASP page using VBScript ?
    >
    >- If not, what is the easiest way to return these parameters ? Where can
    >I find an easy sample of it ?
    >
    >
    >Any help would be much appreciated.
    >
    >Thank you very much
    >
    >Zohar Nissare-Houssen
    >TravelNet Technologies
    >


    Share on Google+

  3. #3
    Zohar Nissare-Houssen Guest

    Re: Returning data from VC++ ASP component


    Hello Scott,

    Thank you very much for your help. The ListServ link you gave me will be
    very useful...
    But I have another question related this time to VBScript language coding
    in ASP
    still related to my problem :-)

    I finally wrote a component method who returns an array of variant. Let's
    say that this method is called
    ReturnArray and takes two IN parameters, I coded the following in my ASP
    page :

    <%set MyObject=Server.CreateObject("ASPCOMPONENT.MYOBJECT")%>
    ...
    Dim foo(3) [or Dim foo()]
    foo = MyObject.ReturnArray(v1,v2)

    This code causes a type mismatch error.

    IsArray( MyObject.ReturnArray(v1,v2) ) returns TRUE
    VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)

    So my return type is recognised as an array by VBScript but I can't pass
    it directly into an array variable. I coded then a
    VBScript procedure copying two arrays, element by element : Sub CopyArray(array_dest,array_origin,nbelements).
    I use it like that

    Dim foo(3)
    CopyArray foo, MyObject.ReturnArray(v1,v2), 3

    This code also causes a type mismatch error on array_origin

    Then, I wrote another method in VC++ returning an element of an array. Let's
    say this method is
    ReturnArrayElem(Array,position)

    In my ASP page this code works :

    foo0 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 0 )
    foo1 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 1 )
    ...

    But the problem is that all the array is processed each time I need an element...

    So, my question is : How can I stock the array resulting from a method call
    in VBscript ? Is it possible ?

    Any idea would be much appreciated.

    Thank you

    Zohar Nissare-Houssen
    TravelNet Technologies





    "Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
    >
    >Hello Zohar. I have very little experience with creating COM components

    via
    >VC++. I've only done this once just to see if I could! :-) You can read
    >about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
    >
    >I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
    >
    >Ask your questions there and you'll get great responses from seasoned pros...
    >
    >Happy Programming!
    >
    > Scott Mitchell
    > mitchell@4guysfromrolla.com
    > http://www.4GuysFromRolla.com
    > http://www.ASPMessageBoard.com
    > http://www.ASPFAQs.com
    >
    >* When you think ASP, think 4GuysFromRolla.com!
    >
    >"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
    >>
    >>Hello,
    >>
    >>I have to write an ASP Component in VC++ who returns multiple variables.
    >>
    >>What is the easiest way to return for example 3 variables from the
    >>VC++ component to an ASP page written in VBScript ?
    >>
    >>- Can I do it using OUT parameters in the methods ; If so, how can I do

    >it
    >>in my C++ method using OLE
    >>Automation ? And how can I code it in my ASP page using VBScript ?
    >>
    >>- If not, what is the easiest way to return these parameters ? Where can
    >>I find an easy sample of it ?
    >>
    >>
    >>Any help would be much appreciated.
    >>
    >>Thank you very much
    >>
    >>Zohar Nissare-Houssen
    >>TravelNet Technologies
    >>

    >


    Share on Google+

  4. #4
    Scott Mitchell Guest

    Re: Returning data from VC++ ASP component


    Have you tried:
    Dim foo
    foo = MyObject.ReturnArray(v1,v2)

    ???

    "Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
    >
    >Hello Scott,
    >
    >Thank you very much for your help. The ListServ link you gave me will be
    >very useful...
    >But I have another question related this time to VBScript language coding
    >in ASP
    >still related to my problem :-)
    >
    >I finally wrote a component method who returns an array of variant. Let's
    >say that this method is called
    >ReturnArray and takes two IN parameters, I coded the following in my ASP
    >page :
    >
    ><%set MyObject=Server.CreateObject("ASPCOMPONENT.MYOBJECT")%>
    >...
    >Dim foo(3) [or Dim foo()]
    >foo = MyObject.ReturnArray(v1,v2)
    >
    >This code causes a type mismatch error.
    >
    >IsArray( MyObject.ReturnArray(v1,v2) ) returns TRUE
    >VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)
    >
    >So my return type is recognised as an array by VBScript but I can't pass
    >it directly into an array variable. I coded then a
    >VBScript procedure copying two arrays, element by element : Sub CopyArray(array_dest,array_origin,nbelements).
    >I use it like that
    >
    >Dim foo(3)
    >CopyArray foo, MyObject.ReturnArray(v1,v2), 3
    >
    >This code also causes a type mismatch error on array_origin
    >
    >Then, I wrote another method in VC++ returning an element of an array. Let's
    >say this method is
    >ReturnArrayElem(Array,position)
    >
    >In my ASP page this code works :
    >
    >foo0 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 0 )
    >foo1 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 1 )
    >...
    >
    >But the problem is that all the array is processed each time I need an element...
    >
    >So, my question is : How can I stock the array resulting from a method

    call
    >in VBscript ? Is it possible ?
    >
    >Any idea would be much appreciated.
    >
    >Thank you
    >
    >Zohar Nissare-Houssen
    >TravelNet Technologies
    >
    >
    >
    >
    >
    >"Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
    >>
    >>Hello Zohar. I have very little experience with creating COM components

    >via
    >>VC++. I've only done this once just to see if I could! :-) You can read
    >>about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
    >>
    >>I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
    >>
    >>Ask your questions there and you'll get great responses from seasoned pros...
    >>
    >>Happy Programming!
    >>
    >> Scott Mitchell
    >> mitchell@4guysfromrolla.com
    >> http://www.4GuysFromRolla.com
    >> http://www.ASPMessageBoard.com
    >> http://www.ASPFAQs.com
    >>
    >>* When you think ASP, think 4GuysFromRolla.com!
    >>
    >>"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
    >>>
    >>>Hello,
    >>>
    >>>I have to write an ASP Component in VC++ who returns multiple variables.
    >>>
    >>>What is the easiest way to return for example 3 variables from the
    >>>VC++ component to an ASP page written in VBScript ?
    >>>
    >>>- Can I do it using OUT parameters in the methods ; If so, how can I do

    >>it
    >>>in my C++ method using OLE
    >>>Automation ? And how can I code it in my ASP page using VBScript ?
    >>>
    >>>- If not, what is the easiest way to return these parameters ? Where can
    >>>I find an easy sample of it ?
    >>>
    >>>
    >>>Any help would be much appreciated.
    >>>
    >>>Thank you very much
    >>>
    >>>Zohar Nissare-Houssen
    >>>TravelNet Technologies
    >>>

    >>

    >


    Share on Google+

  5. #5
    Zohar Nissare-Houssen Guest

    Re: Returning data from VC++ ASP component


    Hi Scott,

    I finally solved my problem. It was not a VBScript problem. The problem was
    on the Array type returned
    by my component method.

    From VBScript, the good hint that helped me was that :

    VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)

    And, In fact, I learned that you can never get VarType of only 8192 - it
    always has to be an array of
    something (And as return result from COM objects, VBScript only supports
    ARRAY of VARIANTS)

    So, I should have get the following value for an array of nb=2 elements :

    8204 = 1* (vbArray=8192) + (nb-1)*(vbVariant=12)

    Another VBScript function is also very useful : TypeName(MyObject.ReturnArray(v1,v2))
    to check
    return array from COM VB/VC Component. It should always return string "Variant()"
    for an
    array of variant.

    Zohar

    "Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
    >
    >Have you tried:
    >Dim foo
    >foo = MyObject.ReturnArray(v1,v2)
    >
    >???
    >
    >"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
    >>
    >>Hello Scott,
    >>
    >>Thank you very much for your help. The ListServ link you gave me will be
    >>very useful...
    >>But I have another question related this time to VBScript language coding
    >>in ASP
    >>still related to my problem :-)
    >>
    >>I finally wrote a component method who returns an array of variant. Let's
    >>say that this method is called
    >>ReturnArray and takes two IN parameters, I coded the following in my ASP
    >>page :
    >>
    >><%set MyObject=Server.CreateObject("ASPCOMPONENT.MYOBJECT")%>
    >>...
    >>Dim foo(3) [or Dim foo()]
    >>foo = MyObject.ReturnArray(v1,v2)
    >>
    >>This code causes a type mismatch error.
    >>
    >>IsArray( MyObject.ReturnArray(v1,v2) ) returns TRUE
    >>VarType( MyObject.ReturnArray(v1,v2) ) returns 8192 (vbArray constant)
    >>
    >>So my return type is recognised as an array by VBScript but I can't pass
    >>it directly into an array variable. I coded then a
    >>VBScript procedure copying two arrays, element by element : Sub CopyArray(array_dest,array_origin,nbelements).
    >>I use it like that
    >>
    >>Dim foo(3)
    >>CopyArray foo, MyObject.ReturnArray(v1,v2), 3
    >>
    >>This code also causes a type mismatch error on array_origin
    >>
    >>Then, I wrote another method in VC++ returning an element of an array.

    Let's
    >>say this method is
    >>ReturnArrayElem(Array,position)
    >>
    >>In my ASP page this code works :
    >>
    >>foo0 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 0 )
    >>foo1 = MyObject.ReturnArrayElem( MyObject.ReturnArray(v1,v2) , 1 )
    >>...
    >>
    >>But the problem is that all the array is processed each time I need an

    element...
    >>
    >>So, my question is : How can I stock the array resulting from a method

    >call
    >>in VBscript ? Is it possible ?
    >>
    >>Any idea would be much appreciated.
    >>
    >>Thank you
    >>
    >>Zohar Nissare-Houssen
    >>TravelNet Technologies
    >>
    >>
    >>
    >>
    >>
    >>"Scott Mitchell" <mitchell@4guysfromrolla.com> wrote:
    >>>
    >>>Hello Zohar. I have very little experience with creating COM components

    >>via
    >>>VC++. I've only done this once just to see if I could! :-) You can

    read
    >>>about my attempts at: http://www.4guysfromrolla.com/webtech/052600-1.shtml
    >>>
    >>>I'd also HIGHLY recommend that you join this ListServ: http://www.asplists.com/asplists/asp...components.asp
    >>>
    >>>Ask your questions there and you'll get great responses from seasoned

    pros...
    >>>
    >>>Happy Programming!
    >>>
    >>> Scott Mitchell
    >>> mitchell@4guysfromrolla.com
    >>> http://www.4GuysFromRolla.com
    >>> http://www.ASPMessageBoard.com
    >>> http://www.ASPFAQs.com
    >>>
    >>>* When you think ASP, think 4GuysFromRolla.com!
    >>>
    >>>"Zohar Nissare-Houssen" <znissare@travelnet.ca> wrote:
    >>>>
    >>>>Hello,
    >>>>
    >>>>I have to write an ASP Component in VC++ who returns multiple variables.
    >>>>
    >>>>What is the easiest way to return for example 3 variables from the
    >>>>VC++ component to an ASP page written in VBScript ?
    >>>>
    >>>>- Can I do it using OUT parameters in the methods ; If so, how can I

    do
    >>>it
    >>>>in my C++ method using OLE
    >>>>Automation ? And how can I code it in my ASP page using VBScript ?
    >>>>
    >>>>- If not, what is the easiest way to return these parameters ? Where

    can
    >>>>I find an easy sample of it ?
    >>>>
    >>>>
    >>>>Any help would be much appreciated.
    >>>>
    >>>>Thank you very much
    >>>>
    >>>>Zohar Nissare-Houssen
    >>>>TravelNet Technologies
    >>>>
    >>>

    >>

    >


    Share on Google+

Similar Threads

  1. Replies: 0
    Last Post: 10-16-2002, 01:31 PM
  2. Data Typing and Error Handling btwn COM and ASP
    By Paul Klanderud in forum ASP.NET
    Replies: 0
    Last Post: 02-04-2001, 04:24 PM
  3. Replies: 4
    Last Post: 11-01-2000, 03:59 PM
  4. Replies: 1
    Last Post: 10-17-2000, 09:17 AM
  5. How to lock a row when updating data with ASP and SQL
    By C. Liacopoulos in forum authorevents.mitchell
    Replies: 0
    Last Post: 10-17-2000, 01:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center