MoveFirst in recordset

Results 1 to 3 of 3

Thread: MoveFirst in recordset

  1. #1
    Join Date
    Dec 1969

    Default MoveFirst in recordset

    I have a recordset which I assign from a command.execute i then loop through it once writing out some client side jscript i then want to move to the beginning of the recordset and loop through it again to do something else. However when I use objRec.movefirst I get the following error.<BR><BR>Error Type:<BR>Microsoft OLE DB Provider for ODBC Drivers (0x80040E18)<BR>Rowset position cannot be restarted.<BR><BR>Why is this I have tried setting my rst obj to have a dynamic cursor but to no avail. I have read in books that u can move back and forth with a recordset.<BR><BR>My code is<BR><BR>set objComPred = Server.CreateObject("ADODB.Command")<BR> set objRecPred = Server.CreateObject("ADODB.Recordset")<BR> <BR> <BR> objComPred.ActiveConnection = objCon2<BR> objComPred.CommandType = adCmdStoredProc<BR> objComPred.CommandText= "usp_asp_get_predictive_menu"<BR> objComPred.Parameters.append objComPred.CreateParameter("@Agent_id",adInteger,a dParamInput,0,Session("Agent_ID"))<BR> set objRecPred = objComPred.Execute<BR><BR><BR><BR>Response.Write(" &#060;script LANGUAGE=""javascript""&#062;")<BR> Response.Write("&#060;!--")<BR> <BR> if(not objRecPred.BOF And not objRecPred.EOF) then <BR> <BR> Do While not objRecPred.EOF<BR> Response.Write(vbCrLf)<BR> Response.Write("function " & objRecPred("Code") & "(){" & vbCrLf)<BR> Response.Write("var block = document.frmDialer.txtBlock.value;" & vbCrLf)<BR> Response.Write("var blockdesc = document.frmDialer.txtBlockName.value;" & vbCrLf)<BR> Response.write("if(block==""""){"&vbCrLf)<BR> Response.Write("alert(""A Block must be selected first!"")"&vbCrLf)<BR> Response.Write("document.all."&objRecPred("code")& ".href = ""Dialer.asp"""&vbCrLf)<BR> Response.Write("}else{"&vbCrLf)<BR> Response.Write("document.all."&objRecPred("code")& ".href = """ & objRecPred("href") & "?Block="" + block + ""&Name="" + blockdesc"&vbCrLf)<BR> Response.Write("}"& vbCrLf) <BR> Response.Write("}")<BR> Response.Write(vbCrLf)<BR> objRecPred.movenext<BR> Loop<BR> <BR> objRecPred.MoveFirst<BR> <BR> end if<BR><BR> Response.Write("//--&#062;")<BR> Response.Write("&#060;/script&#062;")

  2. #2
    Join Date
    Dec 1969

    Default by default

    the recordset is farwardonly.<BR><BR>Make it a keyset or dynamic cursor type.

  3. #3
    Join Date
    Dec 1969

    Default I didn't check your code but...

    most time that I have to go through a dataset more than once, I would stick it into an array using getrows() rather than navigate back & forth through the (possibly) large recordset.

Posting Permissions

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