p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Re: howto pass a recordset from ASP to a VB component?


Message #1 by "Imar Spaanjaars" <Imar@S...> on Thu, 13 Jun 2002 22:14:06
Hi there,

VB 6 default method for passing parameters is ByRef (a reference to the 
object is passed, not the actual object). Since ASP doesn't know real 
datatypes (only Variants), you can't just pass an ASP recordset to a 
method that expects a strongly typed object.

Either change your Datatype to a variant (ByRef rsMyRs As Variant) or 
change the type to ByVal (ByVal rsMyRs As ADODB.Recordset)

In the first scenario, you might need to do some casting to change the 
variant to a proper recordset.

I haven't tested this, so I am not 100% sure you can pass recordsets like 
this (all kinds of troubles related to connections etc).

IMO, I wouldn't pass a recordset, but just the data that you need to 
access in your VB method.

Check out the following KB article for more info about ByRef Vs ByVal.

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


HtH

Imar





> Hello,

> when I try to pass a recordset from ASP to a Visual Basic component, I 
get 
t> he error 800a000d (types incompatible). (It works fine for simple 
v> ariables like integer, string, etc.)

> The function of my DLL looks like this:

> > Public Function Function1 (rsMyRs As ADODB.Recordset)
>>  ...

> and is invoked by ASP with

> > Set rsTemp  = CreateObject("ADODB.Recordset")
>>  Set objMain = Server.CreateObject("MyDll.MyComponent")
>>  ... 
>>       'fill rsTemp with data
>>  ...
>>  objMain.Function1 rsTemp

> 
C> an anybody help me? What am I doing wrong here? Or isn't it possible 
to 
p> ass recordsets to a dll??

> Thanx for any help.

> Flummi
Message #2 by kev_web25@b... on Thu, 13 Jun 2002 11:41:14
Just an idea although it probably wont work...

Make sure that you have the most up-to-date version of MDAC (Microsoft 
Data Access Components) installed, you can check by going to the microsoft 
web site and doing a search for MDAC. I think the latest version is 2.7 
but i may be wrong.

Kev
Message #3 by "flummi" <flummi@e...> on Mon, 3 Jun 2002 13:51:36
Hello,

when I try to pass a recordset from ASP to a Visual Basic component, I get 
the error 800a000d (types incompatible). (It works fine for simple 
variables like integer, string, etc.)

The function of my DLL looks like this:

> Public Function Function1 (rsMyRs As ADODB.Recordset)
> ...

and is invoked by ASP with

> Set rsTemp  = CreateObject("ADODB.Recordset")
> Set objMain = Server.CreateObject("MyDll.MyComponent")
> ... 
>      'fill rsTemp with data
> ...
> objMain.Function1 rsTemp


Can anybody help me? What am I doing wrong here? Or isn't it possible to 
pass recordsets to a dll??

Thanx for any help.

Flummi

  Return to Index