Returning Recordset to ASP 
Author Message
 Returning Recordset to ASP

Hi, I'm a having some problems with getting my VB COM DLL to return a
recordset.  Actually, I'm not sure what I'm doing wrong. The error that
I get is
Microsoft VBScript runtime error '800a000d'
Type mismatch: 'DatabaseTest'
/stuff/vbcomTest_1.asp, line 11

Here's part of my COM code, followed by a snippet of my ASP. Thanks in
advance:

VB COM:
=====================
Public Function Test()
    Test = "This function works!"
End Function

Public Function DatabaseTest(conn As String, sql As String) As
ADODB.Recordset

    Dim rs As ADODB.Recordset
    Dim c As ADODB.Connection
    On Error GoTo ErrHandler
    Set c = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    c.Open conn
    Set rs = c.Execute(sql)
    Set DatabaseTest = rs

ErrHandler:
    Err.Raise Err.Number, "DatabaseTest", Err.Description
End Function

ASP SNIPPET:
======================
Set MyStuff = Server.CreateObject("MyVBCOM.MyClass")
Set MyRS = MyStuff.DatabaseTest(conn,"SELECT * FROM MyTable")
While Not MyRS.EOF
        Response.Write(MyRS(0) & "," & MyRS(1) & "<br>")
MyRS.MoveNext
Wend

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 30 Jun 2002 03:00:00 GMT  
 Returning Recordset to ASP
Try passing parameters ByVal:

Public Function DatabaseTest(BYVAL conn As String, BYVAL  sql As String) As
ADODB.Recordset

HTH

-Sai


Quote:
> Hi, I'm a having some problems with getting my VB COM DLL to return a
> recordset.  Actually, I'm not sure what I'm doing wrong. The error that
> I get is
> Microsoft VBScript runtime error '800a000d'
> Type mismatch: 'DatabaseTest'
> /stuff/vbcomTest_1.asp, line 11

> Here's part of my COM code, followed by a snippet of my ASP. Thanks in
> advance:

> VB COM:
> =====================
> Public Function Test()
>     Test = "This function works!"
> End Function

> Public Function DatabaseTest(conn As String, sql As String) As
> ADODB.Recordset

>     Dim rs As ADODB.Recordset
>     Dim c As ADODB.Connection
>     On Error GoTo ErrHandler
>     Set c = CreateObject("ADODB.Connection")
>     Set rs = CreateObject("ADODB.Recordset")
>     c.Open conn
>     Set rs = c.Execute(sql)
>     Set DatabaseTest = rs

> ErrHandler:
>     Err.Raise Err.Number, "DatabaseTest", Err.Description
> End Function

> ASP SNIPPET:
> ======================
> Set MyStuff = Server.CreateObject("MyVBCOM.MyClass")
> Set MyRS = MyStuff.DatabaseTest(conn,"SELECT * FROM MyTable")
> While Not MyRS.EOF
> Response.Write(MyRS(0) & "," & MyRS(1) & "<br>")
> MyRS.MoveNext
> Wend

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 30 Jun 2002 03:00:00 GMT  
 Returning Recordset to ASP
I think the problem is that the recordset is not being fully disconnected.

Try:
rs.Open sql, c, adOpenStatic, adLockBatchOptimistic
Set rs.ActiveConnection = Nothing

HTH,
Brian A. Manlove
Magenic Technologies Int'l.


Quote:
> Hi, I'm a having some problems with getting my VB COM DLL to return a
> recordset.  Actually, I'm not sure what I'm doing wrong. The error that
> I get is
> Microsoft VBScript runtime error '800a000d'
> Type mismatch: 'DatabaseTest'
> /stuff/vbcomTest_1.asp, line 11

> Here's part of my COM code, followed by a snippet of my ASP. Thanks in
> advance:

> VB COM:
> =====================
> Public Function Test()
>     Test = "This function works!"
> End Function

> Public Function DatabaseTest(conn As String, sql As String) As
> ADODB.Recordset

>     Dim rs As ADODB.Recordset
>     Dim c As ADODB.Connection
>     On Error GoTo ErrHandler
>     Set c = CreateObject("ADODB.Connection")
>     Set rs = CreateObject("ADODB.Recordset")
>     c.Open conn
>     Set rs = c.Execute(sql)
>     Set DatabaseTest = rs

> ErrHandler:
>     Err.Raise Err.Number, "DatabaseTest", Err.Description
> End Function

> ASP SNIPPET:
> ======================
> Set MyStuff = Server.CreateObject("MyVBCOM.MyClass")
> Set MyRS = MyStuff.DatabaseTest(conn,"SELECT * FROM MyTable")
> While Not MyRS.EOF
> Response.Write(MyRS(0) & "," & MyRS(1) & "<br>")
> MyRS.MoveNext
> Wend

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Sun, 30 Jun 2002 03:00:00 GMT  
 Returning Recordset to ASP
The Type Mismatch is coming from the Parameters being passed in.  Everything
in ASP is typed as variant.  I make it practice when developing COM for ASP
to expose all params as ByVal Variants and then cast them inside the COM
object before working with them.

David.


Quote:
> Hi, I'm a having some problems with getting my VB COM DLL to return a
> recordset.  Actually, I'm not sure what I'm doing wrong. The error that
> I get is
> Microsoft VBScript runtime error '800a000d'
> Type mismatch: 'DatabaseTest'
> /stuff/vbcomTest_1.asp, line 11

> Here's part of my COM code, followed by a snippet of my ASP. Thanks in
> advance:

> VB COM:
> =====================
> Public Function Test()
>     Test = "This function works!"
> End Function

> Public Function DatabaseTest(conn As String, sql As String) As
> ADODB.Recordset

>     Dim rs As ADODB.Recordset
>     Dim c As ADODB.Connection
>     On Error GoTo ErrHandler
>     Set c = CreateObject("ADODB.Connection")
>     Set rs = CreateObject("ADODB.Recordset")
>     c.Open conn
>     Set rs = c.Execute(sql)
>     Set DatabaseTest = rs

> ErrHandler:
>     Err.Raise Err.Number, "DatabaseTest", Err.Description
> End Function

> ASP SNIPPET:
> ======================
> Set MyStuff = Server.CreateObject("MyVBCOM.MyClass")
> Set MyRS = MyStuff.DatabaseTest(conn,"SELECT * FROM MyTable")
> While Not MyRS.EOF
> Response.Write(MyRS(0) & "," & MyRS(1) & "<br>")
> MyRS.MoveNext
> Wend

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 01 Jul 2002 03:00:00 GMT  
 Returning Recordset to ASP
David,

I found that passing the parameters either ByVal or as Variants both
worked, but your method seems more fail-proof.  I try it out.

Thanks for the tip!
Matt



Quote:
> The Type Mismatch is coming from the Parameters being passed in.
Everything
> in ASP is typed as variant.  I make it practice when developing COM
for ASP
> to expose all params as ByVal Variants and then cast them inside the
COM
> object before working with them.

> David.



> > Hi, I'm a having some problems with getting my VB COM DLL to return
a
> > recordset.  Actually, I'm not sure what I'm doing wrong. The error
that
> > I get is
> > Microsoft VBScript runtime error '800a000d'
> > Type mismatch: 'DatabaseTest'
> > /stuff/vbcomTest_1.asp, line 11

> > Here's part of my COM code, followed by a snippet of my ASP. Thanks
in
> > advance:

> > VB COM:
> > =====================
> > Public Function Test()
> >     Test = "This function works!"
> > End Function

> > Public Function DatabaseTest(conn As String, sql As String) As
> > ADODB.Recordset

> >     Dim rs As ADODB.Recordset
> >     Dim c As ADODB.Connection
> >     On Error GoTo ErrHandler
> >     Set c = CreateObject("ADODB.Connection")
> >     Set rs = CreateObject("ADODB.Recordset")
> >     c.Open conn
> >     Set rs = c.Execute(sql)
> >     Set DatabaseTest = rs

> > ErrHandler:
> >     Err.Raise Err.Number, "DatabaseTest", Err.Description
> > End Function

> > ASP SNIPPET:
> > ======================
> > Set MyStuff = Server.CreateObject("MyVBCOM.MyClass")
> > Set MyRS = MyStuff.DatabaseTest(conn,"SELECT * FROM MyTable")
> > While Not MyRS.EOF
> > Response.Write(MyRS(0) & "," & MyRS(1) & "<br>")
> > MyRS.MoveNext
> > Wend

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Sun, 07 Jul 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Returning Recordset to ASP page from .dll

2. Returning Recordset to ASP page from .dll

3. Problems returning recordset to ASP from VB

4. Returning Recordsets in ASP

5. Returning an array of recordsets from a VB6 DLL to ASP

6. REturning recordset from DLL to ASP

7. HowTo return a recordset to ASP from the COM DLL

8. Function return a Recordset in a ASP

9. HowTo return a recordset to ASP from the COM DLL

10. Can VB component return a Recordset to ASP?

11. Can VB component return a Recordset to ASP?

12. return recordset from activex dll to ASP page???

 

 
Powered by phpBB® Forum Software