cozzy1984
01-14-2010, 11:34 AM
Hi I'm using ASP for a project that will allow user to search dates and find the timeslots that are available for an appointment.
I can run queries that bring back the slots that are booked when the user enters a date and can also get all the timeslots of the day (booked or unbooked) But what i really want is somehow to only output the timeslots if it doesnt appear in the booked query.
Im finding this hard to explain.
This query gets the date entered and outputs the timeslots that are booked on that day:
<%
DIm selecteddate
selecteddate = Request.Form("f_date")
Response.Write ("date = " & selecteddate & "<br/>")
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../fpdb/Dentist_appointment_database - Antoine_Backup4_2010-01-12.mdb")
objConn.Open
DIM mySQL
mySQL = "SELECT tblappointmentdate.date, tblappointmenttime.time, tblappointment.[Appointed Dentist ID] FROM tblappointment INNER JOIN (tblappointmentdate INNER JOIN tblappointmenttime ON tblappointmentdate.appointmentref = tblappointmenttime.appointmentref) ON tblappointment.ApppointmentID = tblappointmentdate.appointmentid WHERE (((tblappointmentdate.date)=# " & selecteddate & " #))"
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
<table>
<% Do While not objRS.EOF
%>
<tr><td><% Response.Write objRS("date") %></td>
<td><% Response.Write objRS("time") %></td>
<td><% Response.Write objRS("Appointed Dentist ID") %></td></tr>
<% objRS.MoveNext
Loop %>
</table>
This one outputs the timeslots from a basic table with just all the times available
DIM mySQL1
mySQL1 = "SELECT * FROM tblslot"
DIM objRS1
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open mySQL1, objConn
<table>
<% Do While not objRS1.EOF
DIM timeslot
timeslot = objRS1("Timeslot")
mySQL4 = "SELECT * FROM tblslot"
DIM objRS4
Set objRS4 = Server.CreateObject("ADODB.Recordset")
objRS4.Open mySQL4, objConn
%>
<tr><td><% Response.Write objRS1("Timeslot") %></td></tr>
<% objRS1.MoveNext
Loop %>
</table>
I was hoping to add the first query into the Do While of outputting the timeslots so basically it would only return the slots if the time didnt appear in the returned query results, therefore the time would not be booked on that date.
I hope I've made at least some sense for someone to be able to shed so light on this as its driving me mad. Thanks
I can run queries that bring back the slots that are booked when the user enters a date and can also get all the timeslots of the day (booked or unbooked) But what i really want is somehow to only output the timeslots if it doesnt appear in the booked query.
Im finding this hard to explain.
This query gets the date entered and outputs the timeslots that are booked on that day:
<%
DIm selecteddate
selecteddate = Request.Form("f_date")
Response.Write ("date = " & selecteddate & "<br/>")
DIM objConn
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../fpdb/Dentist_appointment_database - Antoine_Backup4_2010-01-12.mdb")
objConn.Open
DIM mySQL
mySQL = "SELECT tblappointmentdate.date, tblappointmenttime.time, tblappointment.[Appointed Dentist ID] FROM tblappointment INNER JOIN (tblappointmentdate INNER JOIN tblappointmenttime ON tblappointmentdate.appointmentref = tblappointmenttime.appointmentref) ON tblappointment.ApppointmentID = tblappointmentdate.appointmentid WHERE (((tblappointmentdate.date)=# " & selecteddate & " #))"
DIM objRS
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open mySQL, objConn
<table>
<% Do While not objRS.EOF
%>
<tr><td><% Response.Write objRS("date") %></td>
<td><% Response.Write objRS("time") %></td>
<td><% Response.Write objRS("Appointed Dentist ID") %></td></tr>
<% objRS.MoveNext
Loop %>
</table>
This one outputs the timeslots from a basic table with just all the times available
DIM mySQL1
mySQL1 = "SELECT * FROM tblslot"
DIM objRS1
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open mySQL1, objConn
<table>
<% Do While not objRS1.EOF
DIM timeslot
timeslot = objRS1("Timeslot")
mySQL4 = "SELECT * FROM tblslot"
DIM objRS4
Set objRS4 = Server.CreateObject("ADODB.Recordset")
objRS4.Open mySQL4, objConn
%>
<tr><td><% Response.Write objRS1("Timeslot") %></td></tr>
<% objRS1.MoveNext
Loop %>
</table>
I was hoping to add the first query into the Do While of outputting the timeslots so basically it would only return the slots if the time didnt appear in the returned query results, therefore the time would not be booked on that date.
I hope I've made at least some sense for someone to be able to shed so light on this as its driving me mad. Thanks