Hey there.
I have been working all day to get this script down in load up time. I have got it form 21 secs to 3.5 secs (yes i am that sad that I measured it). Anyway even though 3.5 secs is nearly acceptable I still want to get it down further. What it does is display bookings in an inline frame. The code below is from the inline frame. If you fancy like a challenge or something then have a look at the code below and try and find a way of getting down maybe an extra second or so. Any ideas more than welcome.
Many many thanks to anyone who even looks at this code and hope to hear from you soon.
P.S. You might be better copying and pasting this into your preferred editor
[tt]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Change Accomodation Details </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link rel="stylesheet" type="text/css"href="main.css">
</HEAD>
<BODY topmargin="0" leftmargin="0">
<%
sub setColour(dayNow, monthNow, yearNow) 'sub routine to set the colour of the week days
wDay = weekday(cdate(monthNow & "/" & dayNow & "/" & yearNow))
if wDay = 1 or wDay = 7 then
response.write("<font color = '#FF0000'>" & dayNow)
response.write("<br>" & WeekdayName(wDay, true) & "</font>"
else
response.write(dayNow)
response.write("<br>" & WeekdayName(wDay, true))
end if
end sub
dim prop, propArray, monthView, yearView 'request all strings and set up varibles
monthView = Request.QueryString("monthView"
yearView = Request.QueryString("yearView"
props = Request.QueryString("props"
propArray = split(props,"_"
startDate = monthView & "/1/" & yearView
finnishDate = monthView + 1 & "/1/" & yearView
for u = 1 to ubound(propArray)
sql = sql & "bookingStatus = 'book' AND bookingStart >= #" & startDate & "# AND bookingProp = " & propArray(u) & " OR bookingStatus = 'book' AND bookingFinish < #" & finnishDate & "# AND bookingProp = " & propArray(u) & " OR "
sql2 = sql2 & "bookingStatus = 'book' AND bookingStart < #" & startDate & "# AND bookingProp = " & propArray(u) & " AND bookingFinish > #" & startDate & "# OR "
next
sql = (left(sql,(len(sql) - 4)))
sql2 = (left(sql2,(len(sql2) - 4)))
if monthView = "6" or monthView = "9" or monthView = "11" or monthView = "4" then 'get days in month
daysInMonth = 30
elseif monthView = "2" then
daysInMonth = 28
else
daysInMonth = 31
end if
Set bookRS = Server.CreateObject("ADODB.recordset"
Set bookConn = Server.CreateObject("ADODB.Connection"
bookConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
& ";"
strSQL = "SELECT bookingID, bookingStart, bookingFinish, bookingProp, bookingClient FROM booking WHERE " & sql & " ORDER BY bookingStart"
bookRS.Open strSQL, bookConn
response.write("<TABLE class='view'>"
'start table
response.write("<TR>"
'write days ion month
for i = 1 to daysInMonth
response.write("<TD width='60' height='30' class='date' nowrap>"
call setColour(i, monthView, yearView)
response.write("</TD>"
next
response.write("</TR>"
for u = 1 to ubound(propArray)
apartmentFree = "F"
Set book2RS = Server.CreateObject("ADODB.recordset"
Set book2Conn = Server.CreateObject("ADODB.Connection"
book2Conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
& ";"
strSQL = "SELECT bookingID, bookingStart, bookingFinish, bookingProp, bookingClient FROM booking WHERE " & sql2 & " ORDER BY bookingStart"
book2RS.Open strSQL, book2Conn
Do While not book2RS.EOF
if cstr(book2RS("bookingProp"
) = cstr(propArray(u)) then
Set guestRS = Server.CreateObject("ADODB.recordset"
Set guestConn = Server.CreateObject("ADODB.Connection"
guestConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
& ";"
strSQL = "SELECT GuestSurname FROM Guest WHERE GuestID = " & book2RS("bookingClient"
guestRS.Open strSQL, guestConn
apartmentFree = guestRS("GuestSurname"
bookingID = book2RS("bookingID"
guestRS.Close
guestConn.close
set guestRS=Nothing
set guestConn=Nothing
end if
book2RS.MoveNext
loop
book2RS.Close
book2Conn.close
set book2Conn=Nothing
set book2RS=Nothing
response.write("<TR>"
for i = 1 to daysInMonth
response.write("<TD width='60' height='30' class='cell' nowrap>"
Do While not bookRS.EOF
if cstr(bookRS("bookingProp"
) = cstr(propArray(u)) then
if monthView & "/" & (i) & "/" & yearView = cstr(bookRS("bookingFinish"
) then
apartmentFree = "F"
elseif monthView & "/" & (i) & "/" & yearView = cstr(bookRS("bookingStart"
) then
Set guestRS = Server.CreateObject("ADODB.recordset"
Set guestConn = Server.CreateObject("ADODB.Connection"
guestConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
& ";"
strSQL = "SELECT GuestSurname FROM Guest WHERE GuestID = " & bookRS("bookingClient"
guestRS.Open strSQL, guestConn
apartmentFree = guestRS("GuestSurname"
bookingID = bookRS("bookingID"
guestRS.Close
guestConn.close
set guestRS=Nothing
set guestConn=Nothing
end if
end if
bookRS.MoveNext
loop
bookRS.MoveFirst
if apartmentFree = "F" then
response.write("<A HREF='confirm.asp?startdate=" & monthView & "/" & (i) & "/" & yearView & "?=" & propArray(u) &"' TARGET='_top'><font color='#FF0000'>Free</font></A>"
else
response.write("<A HREF='default.asp?Lang=Eng&Page=occupent&booking=" & bookingID & "' TARGET='_top'>" & left(apartmentFree,10) & "</A>"
end if
response.write("</TD>"
next
response.write("</TR>"
next
bookRS.Close
bookConn.close
set bookConn=Nothing
set bookRS=Nothing
response.write("</TABLE>"
%>
</BODY>
</HTML>[/tt]
I have been working all day to get this script down in load up time. I have got it form 21 secs to 3.5 secs (yes i am that sad that I measured it). Anyway even though 3.5 secs is nearly acceptable I still want to get it down further. What it does is display bookings in an inline frame. The code below is from the inline frame. If you fancy like a challenge or something then have a look at the code below and try and find a way of getting down maybe an extra second or so. Any ideas more than welcome.
Many many thanks to anyone who even looks at this code and hope to hear from you soon.
P.S. You might be better copying and pasting this into your preferred editor
[tt]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Change Accomodation Details </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link rel="stylesheet" type="text/css"href="main.css">
</HEAD>
<BODY topmargin="0" leftmargin="0">
<%
sub setColour(dayNow, monthNow, yearNow) 'sub routine to set the colour of the week days
wDay = weekday(cdate(monthNow & "/" & dayNow & "/" & yearNow))
if wDay = 1 or wDay = 7 then
response.write("<font color = '#FF0000'>" & dayNow)
response.write("<br>" & WeekdayName(wDay, true) & "</font>"
else
response.write(dayNow)
response.write("<br>" & WeekdayName(wDay, true))
end if
end sub
dim prop, propArray, monthView, yearView 'request all strings and set up varibles
monthView = Request.QueryString("monthView"
yearView = Request.QueryString("yearView"
props = Request.QueryString("props"
propArray = split(props,"_"
startDate = monthView & "/1/" & yearView
finnishDate = monthView + 1 & "/1/" & yearView
for u = 1 to ubound(propArray)
sql = sql & "bookingStatus = 'book' AND bookingStart >= #" & startDate & "# AND bookingProp = " & propArray(u) & " OR bookingStatus = 'book' AND bookingFinish < #" & finnishDate & "# AND bookingProp = " & propArray(u) & " OR "
sql2 = sql2 & "bookingStatus = 'book' AND bookingStart < #" & startDate & "# AND bookingProp = " & propArray(u) & " AND bookingFinish > #" & startDate & "# OR "
next
sql = (left(sql,(len(sql) - 4)))
sql2 = (left(sql2,(len(sql2) - 4)))
if monthView = "6" or monthView = "9" or monthView = "11" or monthView = "4" then 'get days in month
daysInMonth = 30
elseif monthView = "2" then
daysInMonth = 28
else
daysInMonth = 31
end if
Set bookRS = Server.CreateObject("ADODB.recordset"
Set bookConn = Server.CreateObject("ADODB.Connection"
bookConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
strSQL = "SELECT bookingID, bookingStart, bookingFinish, bookingProp, bookingClient FROM booking WHERE " & sql & " ORDER BY bookingStart"
bookRS.Open strSQL, bookConn
response.write("<TABLE class='view'>"
response.write("<TR>"
for i = 1 to daysInMonth
response.write("<TD width='60' height='30' class='date' nowrap>"
call setColour(i, monthView, yearView)
response.write("</TD>"
next
response.write("</TR>"
for u = 1 to ubound(propArray)
apartmentFree = "F"
Set book2RS = Server.CreateObject("ADODB.recordset"
Set book2Conn = Server.CreateObject("ADODB.Connection"
book2Conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
strSQL = "SELECT bookingID, bookingStart, bookingFinish, bookingProp, bookingClient FROM booking WHERE " & sql2 & " ORDER BY bookingStart"
book2RS.Open strSQL, book2Conn
Do While not book2RS.EOF
if cstr(book2RS("bookingProp"
Set guestRS = Server.CreateObject("ADODB.recordset"
Set guestConn = Server.CreateObject("ADODB.Connection"
guestConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
strSQL = "SELECT GuestSurname FROM Guest WHERE GuestID = " & book2RS("bookingClient"
guestRS.Open strSQL, guestConn
apartmentFree = guestRS("GuestSurname"
bookingID = book2RS("bookingID"
guestRS.Close
guestConn.close
set guestRS=Nothing
set guestConn=Nothing
end if
book2RS.MoveNext
loop
book2RS.Close
book2Conn.close
set book2Conn=Nothing
set book2RS=Nothing
response.write("<TR>"
for i = 1 to daysInMonth
response.write("<TD width='60' height='30' class='cell' nowrap>"
Do While not bookRS.EOF
if cstr(bookRS("bookingProp"
if monthView & "/" & (i) & "/" & yearView = cstr(bookRS("bookingFinish"
apartmentFree = "F"
elseif monthView & "/" & (i) & "/" & yearView = cstr(bookRS("bookingStart"
Set guestRS = Server.CreateObject("ADODB.recordset"
Set guestConn = Server.CreateObject("ADODB.Connection"
guestConn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("db\cpRental.mdb"
strSQL = "SELECT GuestSurname FROM Guest WHERE GuestID = " & bookRS("bookingClient"
guestRS.Open strSQL, guestConn
apartmentFree = guestRS("GuestSurname"
bookingID = bookRS("bookingID"
guestRS.Close
guestConn.close
set guestRS=Nothing
set guestConn=Nothing
end if
end if
bookRS.MoveNext
loop
bookRS.MoveFirst
if apartmentFree = "F" then
response.write("<A HREF='confirm.asp?startdate=" & monthView & "/" & (i) & "/" & yearView & "?=" & propArray(u) &"' TARGET='_top'><font color='#FF0000'>Free</font></A>"
else
response.write("<A HREF='default.asp?Lang=Eng&Page=occupent&booking=" & bookingID & "' TARGET='_top'>" & left(apartmentFree,10) & "</A>"
end if
response.write("</TD>"
next
response.write("</TR>"
next
bookRS.Close
bookConn.close
set bookConn=Nothing
set bookRS=Nothing
response.write("</TABLE>"
%>
</BODY>
</HTML>[/tt]