Type Mismatch returning variant array from COM object 
Author Message
 Type Mismatch returning variant array from COM object

Here's the scenario:

I am using RDS to return a recordset from a server component to the
client. After updating the recordset, I place it into a
multi-dimensional array, along with some other parameters as follows:

Set aryRS(0,0) = objRS
aryRS(0,1) = "UserKey"
aryRS(0,2) = "CheckConstraintSproc"
aryRS(0,3) = True

I pass this array back to the server component to process any
modifications. If all works fine, it comes back to the client just
fine. But, if there is an error that occurs in the component during an
UpdateBatch, and it jumps into my error handling, when it returns to
the client, I get a type mismatch error, and the entire array is empty
as follows:

aryRS(0,0) = Nothing
aryRS(0,1) = Empty
aryRS(0,2) = Empty
aryRS(0,3) = Empty

Of course I am passing this array ByRef, and all my server side
variables are dimensioned as Variant. All works fine when I am using a
VB client to test it, but not so in VBScript.

Even more intriguing is the fact that I also pass an empty array up to
the component along with my aryRS to collect errors as follows:

blnResult = UpdateRS(aryRS, aryErrors)

When I get the type mismatch, the aryErrors is fine, and contains any
error messege that the error handler placed into it.

For more detail into this dilemna, when this information is passed to
the component, I set a temporary recordset to the recordset array
element and do the processing with it, as follows:

Set rsTemp = aryRS(0, 0)
With rsTemp
    .Filter = adFilterPendingRecords
     . . . .
    If .EditMode = adEditDelete Then
        ' do stuff
        .UpdateBatch   ' constraint error occurs here,
                       ' jump to error handler
    End If
End With

Err_Handler:
    ' collect errors and put them into aryErrors
    ' rollback transaction

When we get back to the client, we have a type mismatch
error and the aryRS is as I mentioned earlier, empty.

Any help for this one, will be many times thanked.

Joanthan

Any additional code that is needed to solve
this can be supplied also. . .

Thanks



Tue, 20 Apr 2004 00:26:58 GMT  
 Type Mismatch returning variant array from COM object
Q174576 - HOWTO: Return Arrays from Server-Side Objects in ASP
http://support.microsoft.com/support/kb/articles/Q174/5/76.ASP

Q218454 - HOWTO: Implement Array Arguments in Visual C++ COM Objects for Active Server Pages
http://support.microsoft.com/support/kb/articles/Q218/4/54.ASP

Q217114 - HOWTO: Implement Array Arguments in Visual Basic COM Objects for Active Server Pages
http://support.microsoft.com/support/kb/articles/Q217/1/14.ASP

--
Michael Harris
Microsoft.MVP.Scripting
--


Quote:
> Here's the scenario:

> I am using RDS to return a recordset from a server component to the
> client. After updating the recordset, I place it into a
> multi-dimensional array, along with some other parameters as follows:

> Set aryRS(0,0) = objRS
> aryRS(0,1) = "UserKey"
> aryRS(0,2) = "CheckConstraintSproc"
> aryRS(0,3) = True

> I pass this array back to the server component to process any
> modifications. If all works fine, it comes back to the client just
> fine. But, if there is an error that occurs in the component during an
> UpdateBatch, and it jumps into my error handling, when it returns to
> the client, I get a type mismatch error, and the entire array is empty
> as follows:

> aryRS(0,0) = Nothing
> aryRS(0,1) = Empty
> aryRS(0,2) = Empty
> aryRS(0,3) = Empty

> Of course I am passing this array ByRef, and all my server side
> variables are dimensioned as Variant. All works fine when I am using a
> VB client to test it, but not so in vbscript.

> Even more intriguing is the fact that I also pass an empty array up to
> the component along with my aryRS to collect errors as follows:

> blnResult = UpdateRS(aryRS, aryErrors)

> When I get the type mismatch, the aryErrors is fine, and contains any
> error messege that the error handler placed into it.

> For more detail into this dilemna, when this information is passed to
> the component, I set a temporary recordset to the recordset array
> element and do the processing with it, as follows:

> Set rsTemp = aryRS(0, 0)
> With rsTemp
>     .Filter = adFilterPendingRecords
>      . . . .
>     If .EditMode = adEditDelete Then
>         ' do stuff
>         .UpdateBatch   ' constraint error occurs here,
>                        ' jump to error handler
>     End If
> End With

> Err_Handler:
>     ' collect errors and put them into aryErrors
>     ' rollback transaction

> When we get back to the client, we have a type mismatch
> error and the aryRS is as I mentioned earlier, empty.

> Any help for this one, will be many times thanked.

> Joanthan

> Any additional code that is needed to solve
> this can be supplied also. . .

> Thanks



Tue, 20 Apr 2004 04:44:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Type mismatch when returning a variant array

2. Type mismatch when returning an variant array

3. returning empty variant array from COM object?

4. JavaScript access variant array returned by COM object?

5. call to COM object returns empty variant array???

6. Com+ returns variant array, but

7. Com+ returns variant array, but

8. Variant data types returned in array to VB from OPC automation interface

9. Pass Variant Array to a COM Object

10. Variants vs. Types in COM objects...best practices

11. Type mismatch when calling VB6 COM objects from VB.NET

12. COM error: eVB calling eVC object give type mismatch

 

 
Powered by phpBB® Forum Software