I tried Wrapping code given by Mark  and I could not  get it. 

I have refined the code.
 
I have created a component  which returns a recordset. (Select * from 
authors - Pubs)  
When I used in mts.asp I get only the first record and not able to 
moveNext.
I  get the error "Object doesn't support this property or 
method: 'Eof'  "
I want to fetch all the 24 records from authors table.   Please help
+++++++++++++++++++++++++++++++++++++++++++++

method in VB component - mymts:   mymts.dll

Public Function ReturnRs(strConnect As Variant, strSQL As Variant) As 
ADODB.Recordset
On Error GoTo ehGetRecordset
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open strConnect
rs.CursorLocation = adUseClient
rs.Open strSQL, cn
Set ReturnRs = rs
Exit Function
ehGetRecordset:
Err.Raise Err.Number, Err.Source, Err.Description
End Function

Asp file:  MTS.ASP 

<%@ Language=VBScript Transaction=Required %>
<%

Dim RS
set RS = Server.CreateObject("ADODB.Recordset")
set objAccount = createObject("mymts.resultset")
rs = OBJACCOUNT.ReturnRs 
("Provider=SQLOLEDB;server=sqlserver;database=pubs;user 
id=sa;pwd=mypwd;", "Select * from authors")
  While not rs.Eof
      response.write rs(0).Value
      rs.moveNext
  wend 
set rs = nothing
set objAccount  = nothing
%>

--- In [EMAIL PROTECTED], Mark E 
<[EMAIL PROTECTED]> wrote:
> Try this (watch for wrapping):
>  
> Dim ReturnRS
> set ReturnRS = Server.CreateObject("ADODB.Recordset")
> set ReturnRS =  ReturnRs
("Provider=SQLOLEDB;server=sqlserver;database=pubs;user 
id=sa;pwd=mypwd;", "Select * from authors") 
> If Not ReturnRS.BOF and ReturnRS.EOF Then
>  'We have records.  Display them
>  Do Until ReturnRS.EOF
>   Response.Write (ReturnRS(1).value & "<br>")
>   ReturnRS.MoveNext
>  Loop
> Else
>  'No records to display.
>  Response.Write ("No records to display")
> End If
>     
> set ReturnRS = nothing
>  
> Function ReturnRs(strConnect, strSQL) 
>     Dim cn, rs
>     set cn = server.CreateObject("ADODB.Connection")
>     set rs = server.CreateObject("ADODB.Recordset")
>     cn.Open strConnect
>     'These are not listed in the typelib.
>     rs.CursorLocation = adUseClient
>     'Using the Unspecified parameters, an ADO/R recordset is 
returned.
>     rs.Open strSQL, cn
>     Set ReturnRs = rs
> End Function
>  
> Mark



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/17folB/TM
--------------------------------------------------------------------~-> 

---------------------------------------------------------------------    
 Home       : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
 Post       : [EMAIL PROTECTED]
 Subscribe  : [EMAIL PROTECTED]
 Unsubscribe: [EMAIL PROTECTED]
--------------------------------------------------------------------- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/active-server-pages/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to