Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2004, 03:21 PM
Authorized User
 
Join Date: Feb 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to sinner
Default viewing records

Hey Guys,
Below is the code i am using to view all of the records where state is = to OPEN. It list all of the duplicates but when i select it, it always shows the same record.. I hope i am being clear in what i am trying to do. Any idea????

<html>

<head>
<title>View Tickets</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>

<body>

<p align="center"><br>
</p>
<%
ConnString = "DSN=ticketbackup"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnString,,,adOpenForwardOnly
Set rs = SERVER.CreateObject("ADODB.Recordset")

strSQL = "SELECT * FROM ticket WHERE Ticket_state = 'OPEN' ORDER BY PSAP "

rs.Open strSQL,conn, adOpenStatic

%>

<form name="openedticket">
  <p><select name="open" size="1">
    <option value="NULL">LIST OF OPEN TICKETS BY PSAP</option>
<% Do While Not rs.EOF
                                    Response.Write ("<OPTION value='"& rs("PSAP") & "' >" & rs("PSAP") & "</option> ")
                                    rs.MoveNext
                                Loop
                                rs.Close
                                Set rs=Nothing %> </select><input type="submit" value="View">&nbsp;&nbsp;&nbsp; </p>
</form>

<p>&nbsp;</p>
<%
 Set rs = SERVER.CreateObject("ADODB.Recordset")

     strST=Request.QueryString("open")
     strSQL = "SELECT * FROM ticket WHERE PSAP = '" & strST & "'"

    ' Open Recordset Object
    rs.Open strSQL,conn,adOpenStatic


%>

<table border="1" width="100%">
  <tr>
    <td width="17%"><strong>PSAP NAME:</strong></td>
    <td width="83%"><%= rs.fields("PSAP") %>
</td>
  </tr>
  <tr>
    <td width="17%"><strong>Ticket ID:</strong></td>
    <td width="83%"><%= rs.fields("Ticket_ID") %>
</td>
  </tr>
  <tr>
    <td width="17%"><strong>Contact Number:</strong></td>
    <td width="83%"><%= rs.fields("Contact") %>
</td>
  </tr>
  <tr>
    <td width="17%"><strong>Badge/Name:</strong></td>
    <td width="83%"><%= rs.fields("Badge") %>
</td>
  </tr>
  <tr>
    <td width="17%"><strong>Trunk Number:</strong></td>
    <td width="83%"><%= rs.fields("Trunk") %>
</td>
  </tr>
  <tr>
    <td width="17%"><strong>Reason for Request:</strong></td>
    <td width="83%"><%= rs.fields("Reason") %>
</td>
  </tr>
  <tr>
    <td width="17%"><strong>Comments:</strong></td>
    <td width="83%"><%= rs.fields("Comments") %>
</td>
  </tr>
  <tr>
    <td width="17%">&nbsp;</td>
    <td width="83%">&nbsp;</td>
  </tr>
</table>
</body>
</html>


 
Old March 19th, 2004, 09:28 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

use looping

while not rs.eof
   response.write("<td>Name</td><td>" & rs("name") & "</td>")
rs.moveNext
wend

 
Old March 20th, 2004, 06:08 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

If I understand your problem correctly, it's caused by the fact you are not submitting your page to the server.

Your second recordset tries to retrieve information using the drop-down as a filter. However, Request.QueryString("open") runs at the server, and not at the client.
If the page loads the first time, it will write out the drop down, and then immediately proceed with the second recordset.

Here's what you need to do to fix it:

1. Add an onchange handler to the drop down. Add some code to it that automatically submits the form to the server using something like: document.openedticket.submit();

2. On the server, check whether the QueryString has a value. If it does, it means the form has been submitted to the server, so you can construct your second recordset, like this:
Code:
<%
If Request.QueryString("open") & "" <> "" Then
  ' There is a QueryString, so get the record
  Set rs = Server.CreateObject("ADODB.Recordset")
  strST = Request.QueryString("open")
  strSQL = "SELECT * FROM ticket WHERE PSAP = '" & strST & "'"
  ' Open Recordset Object
  rs.Open strSQL, conn, adOpenStatic
%>
This way, the second code block will only run when the form has been posted back to the server.

Does this help?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in updating records & finding records naveed77 VB Databases Basics 1 January 16th, 2007 12:12 PM
problem in updating records & finding records naveed77 VB How-To 1 January 16th, 2007 12:10 PM
Viewing Multiple Related Records psudireddy Access 1 August 1st, 2006 11:07 PM
No of users viewing ruhin PHP How-To 0 February 9th, 2005 09:50 AM
Viewing Options gmoney060 Classic ASP Basics 2 August 8th, 2004 05:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.