Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Vancouver
    Posts
    17

    Unanswered: help pulling a search from 2 queries

    Hi folks, i have a Search asp page that the users input a startdate and and enddate and then displays the results from a query. Thats all good and works fine, but i am running into a problem when i want to include a second query in my Search and display it.
    Here is some code:
    Code:
    <%
    select case request.querystring("Action")
    case "Search"
    StartDate = Request("startdate")
    EndDate= Request("enddate")
    sql="SELECT * FROM STAServicesQuery WHERE STADate BETWEEN #" & StartDate & "# AND #" & EndDate & "# ORDER BY ""STADate"" ASC " 
        Set rs = Server.CreateObject("ADODB.Recordset")
        rs.Open sql, conn, 3, 3
     end select
    %>
    <%
    Select case request.querystring("Action")
     case "Search"
    %>
    and i display my resulting data using:
    Code:
    <% Do While Not RS.EOF %>
    
      <tr VALIGN="TOP">
        <td><%Response.Write RS("STADate")%></td>
        <td><%Response.Write RS("FullName")%></td>
        <td><%Response.Write RS("Code")%></td>
        <td><%Response.Write RS("Comments")%></td>
      </tr>
        <% RS.MoveNext %><% loop %>  
      </table>
    <% case else%>
    What i want to do is include a second query in my search 'STAInboundQuery', so i thought i could just duplicate my sql stmt as so
    Code:
    sql2="SELECT * FROM STAInboundQuery WHERE STADate BETWEEN #" & StartDate & "# AND #" & EndDate & "# ORDER BY ""STADate"" ASC "
    and then display these in my table as well, but i am not sure how to do this? Will the sql2 stmt be enough? Do i need a 'set rs2 = ......' and an 'rs2.Open sql2 ...' line as well

    I am not sure how to do what i want to do

    any help would be great thanks!!!!
    still in the baby steps of coding

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    Dim Conn, RS, SQL
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open
    Set RS = Server.CreateObject("ADODB.Recordset")
    SQL = "SELECT UserID FROM Users"
    RS.Open SQL, Conn
    Do While Not RS.EOF

    // if you want to open another Record Set here,
    // you need to create another instance of RecordSet
    // Dim RS1
    // Set RS1 = Server.CreateObject("ADODB.Recordset")
    // do something here

    RS.MoveNext
    Loop
    RS.Close

    // if you want to open another Record Set here,
    // you can use RS (do not need to create new one) again
    // since RS is closed

Posting Permissions

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