Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: RE: asp_databases digest: April 26, 2001


Message #1 by "Ravindran" <ravindran.b@i...> on Fri, 27 Apr 2001 20:07:03 +0530
Dear Jean,

The problem is with ur query. Do not use the same variable name as that of

field name to retreive records from the database



Replace

strSQL="Select * from bookings where (bkdate = BkDate) and (roomid=Roomid)"

with

strSQL="Select * from bookings where (bkdate = BkDt) and (roomid=Rid)"



Where Bkdt and Rid are got from the user in the form in Textboxes



Ravindran B

Sr.Analyst

Indus Software Pvt Ltd





Subject: querying sql database

From: Jean Halstad <J_Halstad@S...>

Date: Thu, 26 Apr 2001 10:22:52 +0100

X-Message-Number: 7



Am attempting to display in html table all the room bookings for one of four

rooms on a particular date, after first querying the room identification

table to find out the id of the room requested.



The first time I do the query in IE, if I put in a date which has no

bookings I get the correct response, "No bookings for that date".



If I then put in a query for a date which has bookings I get all of the

bookings for all rooms for all days, and that continues for any subsequent

query I enter, even for dates which have no bookings.



I guess I am doing something very fundamentally wrong, but I can't see what

it is. Can you help me?



<%

'Create & Open bookings recordset

set rsBookings=server.createobject("ADODB.Recordset")

strSQL="Select * from bookings where (bkdate = BkDate) and (roomid=Roomid)"

rsBookings.open strSQL, cn,1,3



if rsbookings.eof then

	response.write ("No bookings on this date. Press Add button to book

")

	response.write strRoomName

else%>



	<form method="post" name="form1" action="deletebooking.asp">

	<table border="1" cellspacing="0" cellpadding="2" width="100%"

summary="formatting table">

		<tr>

		<th>Start Time</th>

		<th>End Time</th>

		<th>Booked by</th>

		<th>Purpose</th>

		<th> </th>

		</tr>

	<%do while not rsbookings.eof%>

		<tr>



		<td><%=rsbookings("starttime")%></td>

		<td><%=rsbookings("endtime")%></td>

		<td><%=rsbookings("bookedby")%></td>

		<td><%=rsbookings("purpose")%></td>

		<td><input type="submit" value="Delete"></td>

		<input type=hidden name="start"

value=<%=rsbookings("starttime")%>



		</tr>

		<%numrows=numrows+1

		rsbookings.movenext

		loop%>

		</table>

	</form>

<%end if

rsBookings.close

set rsBookings = nothing

%>








  Return to Index