Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Type mismatch error when accessing an array

Reply
Thread Tools

Type mismatch error when accessing an array

 
 
leslie_tighe@yahoo.com
Guest
Posts: n/a
 
      10-12-2005
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

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-12-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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...b;EN-US;244012
http://support.microsoft.com/default...b;EN-US;197956

Building COM Components That Take Full Advantage of Visual Basic and
Scripting
http://msdn.microsoft.com/library/te...bscriptcom.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"


 
Reply With Quote
 
 
 
 
leslie_tighe@yahoo.com
Guest
Posts: n/a
 
      10-12-2005
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

 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      10-12-2005
(E-Mail Removed) 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.


 
Reply With Quote
 
leslie_tighe@yahoo.com
Guest
Posts: n/a
 
      10-12-2005
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()

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL Type Mismatch error indexed name returns a value whose type does not match programmingzeal VHDL 0 05-06-2012 06:38 AM
Accessing Web Service from VBA (Type MisMatch) Ayoa ASP .Net Web Services 0 05-30-2006 03:57 PM
type mismatch error amitbadgi@gmail.com ASP .Net 3 08-12-2005 11:23 AM
data type mismatch error amitbadgi@gmail.com ASP .Net 1 08-10-2005 01:04 PM
win32com, string array --> Type mismatch? Harry Pehkonen Python 2 08-11-2003 10:24 PM



Advertisments