|
 |
asp_databases thread: select problem
Message #1 by Jean Halstad <J_Halstad@S...> on Wed, 25 Apr 2001 11:38:38 +0100
|
|
Am trying to select and display in a HTML table room bookings for a
particular room on a particular date from an SQL table. I am using the
roomid and the booking date as the selection criteria.
What I am getting is all of the bookings contained in the table.
What am I doing wrong?
'Create & Open data connection
'set cn=server.createobject("ADODB.Connection")
'cn.open Session("roombook2_ConnectionString")
'Create & Open bookings recordset
set rsBookings=server.createobject("ADODB.Recordset")
strSQL="Select * from bookings where (bkdate = BkDate) and (roomid=Roomid)"
rsBookings.open strSQL, cn
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>
<%rsbookings.movenext
loop%>
</table>
</form>
<%end if
rsBookings.close
%>
Message #2 by "Rick Brose" <brose@u...> on Wed, 25 Apr 2001 17:46:19
|
|
try something like this for the string:
strSQL = "Select * from bookings where bkdate ='" & BkDate & "' AND
roomid='" & Roomid & "'"
That should do it for you.
> Am trying to select and display in a HTML table room bookings for a
> particular room on a particular date from an SQL table. I am using the
> roomid and the booking date as the selection criteria.
> What I am getting is all of the bookings contained in the table.
>
> What am I doing wrong?
>
> 'Create & Open data connection
> 'set cn=server.createobject("ADODB.Connection")
> 'cn.open Session("roombook2_ConnectionString")
> 'Create & Open bookings recordset
> set rsBookings=server.createobject("ADODB.Recordset")
> strSQL="Select * from bookings where (bkdate = BkDate) and
(roomid=Roomid)"
> rsBookings.open strSQL, cn
>
> 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>
> <%rsbookings.movenext
> loop%>
> </table>
> </form>
> <%end if
> rsBookings.close
> %>
>
|
|
 |