Type mismatch error when accessing an array

Discussion in 'ASP General' started by leslie_tighe@yahoo.com, Oct 12, 2005.

  1. Guest

    Hello,


    I have a method on a com+ object that is returning an array of objects.

    I know the array is popluated as calls to check the ubound and lbound
    show valid values. However, any calls to get the value of a cell in the

    array results in a type mismatch error.


    Microsoft VBScript runtime (0x800A000D)
    Type mismatch
    /idmTest/userTest.asp, line 30


    I have pasted below some of the samples that i have tried. Each results

    in the error above. Any suggestions on how I can access this object
    would be helpful.


    ' Call to get the array and to validate that it is an array.
    Set userObj = Server.CreateObject("idmVBApi.ComUser")
    userGrpAry = userObj.getUserGroups(5790)
    arySize = ubound(userGrpAry)


    response.write "userGrpAry size = " & lbound(userGrpAry) & " - " &
    arySize & "<br>"
    response.write "userGrpAry type isArray = " & isArray(userGrpAry) &
    "<br>"


    ' the following fails
    dim index
    for index = lbound(userGrpAry) to ubound(userGrpAry)
    response.Write "type = " & isobject(userGrpAry(index))
    response.write userGrpAry(index).grpName
    next


    Calls to isNull(userGrpAry(index)) also fail.


    Regards
    Leslie
    , Oct 12, 2005
    #1
    1. Advertising

  2. wrote:
    > Hello,
    >
    >
    > I have a method on a com+ object that is returning an array of
    > objects.


    It's hard to say without having first-hand access to your code. Hopefully
    what's written in these articles will help:

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;244012
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;197956

    Building COM Components That Take Full Advantage of Visual Basic and
    Scripting
    http://msdn.microsoft.com/library/techart/msdn_vbscriptcom.htm

    Q218454 - HOWTO: Implement Array Arguments in Visual C++ COM Objects for
    Active Server Pages
    http://support.microsoft.com/default.aspx?kbid=218454

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Oct 12, 2005
    #2
    1. Advertising

  3. Guest

    Bob,

    Thanks for your help. I have pasted the code below withe some comments
    to explain what I am doing. What is interesting is that I can access
    the object just fine in VB.net. Its just through asp that i am
    struggling.

    ' Com+ object code
    <ComClass(ComUser.ClassId, ComUser.InterfaceId, ComUser.EventsId)> _
    Public Class ComUser

    #Region "COM GUIDs"
    ' These GUIDs provide the COM identity for this class
    ' and its COM interfaces. If you change them, existing
    ' clients will no longer be able to access the class.
    Public Const ClassId As String =
    "DDCA1246-62B9-40C2-B9DD-926808410D9C"
    Public Const InterfaceId As String =
    "0175C8FD-E0F1-4FEE-A0B4-48EE6C39DDF8"
    Public Const EventsId As String =
    "A7C3EE87-2BDB-4697-8781-F3CB6F68A46D"
    #End Region

    ' A creatable COM class must have a Public Sub New()
    ' with no parameters, otherwise, the class will not be
    ' registered in the COM registry and cannot be created
    ' via CreateObject.
    Public Sub New()
    MyBase.New()
    End Sub

    Public ComUser()

    Public Function getUserGroups(ByVal userId As String) As
    WSGroupValue()
    Dim user As UserService
    user = New UserService
    Return user.getUserGroups(userId)
    End Function

    End Class

    ' asp code to call this object and related method
    ' this part works
    Dim userObj
    Dim grpVal
    dim arySize

    Set userObj = Server.CreateObject("idmVBApi.ComUser")
    userGrpAry = userObj.getUserGroups(5790)
    arySize = ubound(userGrpAry)

    response.write "userGrpAry size = " & lbound(userGrpAry) & " - " &
    arySize
    response.write "userGrpAry type isArray = " & isArray(userGrpAry)

    dim index
    for index = lbound(userGrpAry) to ubound(userGrpAry)
    ' ***** each of these calls fails *****
    response.Write "type = " & isobject(userGrpAry(index))
    grpval = userGrpAry(index)
    response.Write "Grp name = " & grpVal.grpName & "<br>"
    next
    , Oct 12, 2005
    #3
  4. wrote:
    > Bob,
    >
    > Thanks for your help. I have pasted the code below withe some comments
    > to explain what I am doing. What is interesting is that I can access
    > the object just fine in VB.net. Its just through asp that i am
    > struggling.


    That makes the articles i provided extremely relevant. Don't forget that
    vbscript is a loosely-typed language, which makes communicating with a
    strongly-typed language like VB.Net very tricky. Please carefully read those
    articles. I'm sure at least one of them will contain the key to your
    problem.

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Oct 12, 2005
    #4
  5. Guest

    Thanks Bob.

    The answer was that in needed to return an array of objects and not an
    array of a type.
    ie. object() vs. WSGroupValue()
    , Oct 12, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. data type mismatch error

    , Aug 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    626
    Karl Seguin
    Aug 10, 2005
  2. type mismatch error

    , Aug 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,340
    Kevin Spencer
    Aug 12, 2005
  3. Harry Pehkonen

    win32com, string array --> Type mismatch?

    Harry Pehkonen, Aug 8, 2003, in forum: Python
    Replies:
    2
    Views:
    1,847
    Harry Pehkonen
    Aug 11, 2003
  4. Ayoa

    Accessing Web Service from VBA (Type MisMatch)

    Ayoa, May 30, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    209
  5. programmingzeal
    Replies:
    0
    Views:
    1,092
    programmingzeal
    May 6, 2012
Loading...

Share This Page