If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > help pulling a search from 2 queries

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-20-04, 15:04
jaberwocky jaberwocky is offline
Registered User
 
Join Date: Feb 2004
Location: Vancouver
Posts: 17
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
Reply With Quote
  #2 (permalink)  
Old 02-20-04, 22:40
gyuan gyuan is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On