Results 1 to 3 of 3

Thread: Passing an Array from ASP to COM (that runs in MTS)

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    5

    Passing an Array from ASP to COM (that runs in MTS)

    I have created a COM component that runs under MTS. It has a function that accepts an array as a parameter.
    When I try to call that function from ASP I get an error:
    Err.Number = 13
    Err.Description: Type mismatch
    Err.Source: VB Script runtime

    The code that I use in ASP is:

    <%@ Language=VBScript %>
    <%

    Dim str, obj, retval

    str = "Some String"

    dim ar(1,2)
    ar(0,0) = "String1"
    ar(0,1) = "String2"
    ar(0,2) = "String3"

    ar(1,0) = "String4"
    ar(1,1) = "String5"
    ar(1,2) = "String6"


    set obj = Server.CreateObject("CompLib.Class1")

    retval = obj.FuncName(ar,str)

    %>

    All the datatypes of parameters defined in COM are Variant

    I would be very grateful if sb. can give me any suggestion.

  2. #2
    Hyperactive Member Anglo Saxon's Avatar
    Join Date
    Mar 2002
    Location
    Durham, UK
    Posts
    259
    I suspect that your problem lies in the function parameter definition.

    Based on the code you provided :

    str = "Some String"

    dim ar(1,2)
    ar(0,0) = "String1"
    ar(0,1) = "String2"
    ar(0,2) = "String3"

    ar(1,0) = "String4"
    ar(1,1) = "String5"
    ar(1,2) = "String6"

    If the function declaration were like this :

    FuncName(ByRef a() as variant, ByVal s as string) as variant

    then this call ; retval = obj.FuncName(ar,str)

    would fail and give you a type mismatch, however if you did this :

    FuncName(ByRef a as variant, ByVal s as string) as variant

    then you would be OK!

    Any help?

    --
    Anglo Saxon

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Posts
    5
    Thank you very much Anglo Saxon. Your solution worked fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width