Results 1 to 2 of 2

Thread: paging

  1. #1
    Join Date
    Dec 1969

    Default paging

    Hello: here&#039;s a function that calls a stored procedure(all functions are placed on one page)...this one calls a store procedure<BR><BR>Function getAddress_promotion(ByVal store_city)<BR>Const adInteger = 3<BR>Const adVarChar = 200<BR>Const adParamInput = &H0001<BR>Const adParamOutput = &H0002<BR>Const adParamReturnValue = &H0004<BR>cmdTemp.CommandType = adCmdStoredProc <BR>cmdTemp.CommandText = "sp_rv_GetStoreAddress_promotion"<BR>cmdTemp.Param eters.Append cmdTemp.CreateParameter("@store_city", adVarChar, adParamInput, 50, store_city)<BR>cmdTemp.CommandTimeout = 60 &#039;timeout in one minutes<BR>Set rs = Server.CreateObject("ADODB.RecordSet")<BR>Set rs = cmdTemp.Execute<BR>set getAddress_promotion = rs<BR>End Function<BR><BR>In a another page where I want to page the rusults I call the function:<BR>set rsLocation = getAddress_promotion(store_city) <BR><BR>Problem: where do I place this line?<BR>rsLocation.CursorLocation = adUseClient<BR><BR>if I place it before: <BR>rsLocation.CursorLocation = adUseClient <BR>set rsLocation = getAddress_promotion(store_city)<BR>I get an error: object required<BR>If I place it after I get:<BR>Operation is not allowed when the object is open.<BR><BR>Thanks

  2. #2
    Join Date
    Dec 1969

    Default Think about it...

    *WHERE* do you *ACTUALLY* open any recordset object??<BR><BR>Certainly *this* line doesn&#039;t do so:<BR> set rsLocation = getAddress_promotion(store_city) <BR><BR>All that does is call a function that returns an ALREADY-OPEN recordset, yes?<BR><BR>And then what does the error message say?<BR> Operation is not allowed when the object is open.<BR><BR>So, obviously, you need to perform the operation on the recordset object *after* it is created and *before* it is opened.<BR><BR>But...<BR><BR>But in the code you have, *THERE IS NO SUCH POINT IN TIME*!<BR><BR>You do this:<BR> Set rs = Server.CreateObject("ADODB.RecordSet")<BR> Set rs = cmdTemp.Execute<BR> set getAddress_promotion = rs<BR><BR>For starter, the first of those three lines is a waste of code. Because the middle line *always* returns a *BRAND NEW* recordset object!<BR><BR>So you need to change your code:<BR> Set rs = Server.CreateObject("ADODB.RecordSet") &#039; object created<BR> rs.CursorLocation = adUseClient &#039; but not yet open<BR> rs.Open cmdTemp &#039; *NOW* you can open it!<BR> set getAddress_promotion = rs<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts