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
Raj <[EMAIL PROTECTED]> wrote:
I am unable to get all the records from the recordset. Please guide.
I get only "White" for nine time. Please help
+++++++++++++++++++++++++++++++++++++++++++++
method in my component - mymts:
Public Function ReturnRs(strConnect As Variant, strSQL As Variant) _
As ADODB.Recordset
'Returns an ADODB recordset.
On Error GoTo ehGetRecordset
Dim cn As New ADODB.Connection
Dim rs As New 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
Exit Function
ehGetRecordset:
Err.Raise Err.Number, Err.Source, Err.Description
End Function
Asp file:
<%@ Language=VBScript Transaction=Required %>
<%
set ObjContext = ObjectContext
set objAccount = createObject("mymts.resultset")
rs = OBJACCOUNT.ReturnRs
("Provider=SQLOLEDB;server=sqlserver;database=pubs;user
id=sa;pwd=mypwd;", "Select * from authors")
for each obj in rs
Response.Write rs(1)& "<br>"
next
set con1 = nothing
set rs1 = nothing
%>
---------------------------------------------------------------------
Home : http://groups.yahoo.com/group/active-server-pages
---------------------------------------------------------------------
Post : [EMAIL PROTECTED]
Subscribe : [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
---------------------------------------------------------------------
Yahoo! Groups SponsorADVERTISEMENT
---------------------------------
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 the Yahoo! Terms of Service.
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/