Open two Recordsets in one page? am i mad?

Results 1 to 2 of 2

Thread: Open two Recordsets in one page? am i mad?

  1. #1
    chris beaumont Guest

    Default Open two Recordsets in one page? am i mad?

    Im trying to open two recordsets using ADO in the same ASP page. The first simply checks if a filed is allready in a database and if not, enters a load of other fields. The second uses and SQL statement like so :<BR><BR>SQL = "SELECT blah blah blah"<BR>objRS2 = Server.createobject("adodb.Recordset")<BR>objRS2(S QL)<BR><BR>and then I close it and clean up. BUT when i run this iget this error :<BR>ADODB.Recordset error &#039 800a0e79&#039 <BR><BR>The operation requested by the application is not allowed if the object is open. <BR><BR>/sysarch/database_testing.asp, line 79 <BR><BR>.....anyway around this.<BR><BR>ALTERNITAVELY - does anyone know how to retrieve the highest number from a column of numbers in a database without using an SQL statement?<BR><BR>Cheers big Chris

  2. #2
    Jobba Guest

    Default RE: Open two Recordsets in one page? am i mad?

    If your second recordset is running within a loop, then set up both recordsets first and create a loop within a loop. You&#039ll need to close rs2 before each step in the outer loop.<BR><BR>A hastily written example, may give you the idea.<BR><BR>Dim Sql1, Sql2, rs1, rs2, conn &#039previously defined<BR><BR>Sql1="blah,blah,blah"<BR>Sql2="dade dadeda"<BR><BR>Set rs1=Server.CreateObject("ADODB.Recordset")<BR>Set rs2=Server.CreateObject("ADODB.Recordset")<BR>rs1. open Sql1, conn<BR>Do until rs1.eof<BR> <BR> Sql2, conn<BR> Do until rs2.eof<BR> response.write "whatever you want"<BR> rs2.movenext<BR> Loop<BR> rs2.close<BR><BR>rs1.movenext<BR>Loop<BR>rs1.close

Posting Permissions

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