Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions and ResorcdSets

Status
Not open for further replies.

mousematt

MIS
Feb 5, 2001
102
GB
I'm trying to pass a recordset out of a function like:-
<%
Function getData(sql)
Dim objConn
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
objConn.ConnectionString = MM_connHelpdesk_STRING
objConn.Open
Dim objRS
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
objRS.CursorLocation = adUseClient
objRS.CursorType = adOpenStatic
objRS.Locktype = adLockReadOnly
objRS.Open sql, objConn

getData = objRS

Set objRS.ActiveConnection = Nothing
objConn.Close
objRS.Close
Set objConn = Nothing
Set objRS = Nothing
End Function
%>
<%
Dim objRS
Set objRS = getData(&quot;Select * From users&quot;)
%>
Now that doesn't come up with any errors so I thought I'd got it but when I do
<%objRS.MoveNext%>
or any other method it says it can't do that.... help.
 
You are closeing the recordset!

Don't close it. Remember what you have when you pass the recordset back is two references to the same object until you set the local reference to nothing so when you close objRS you are closing the recordset that the function is passing back.

James :) James Culshaw
jculshaw@miniaturereview.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top