Hello, my website is here:
http://londonheathrowcars.com/01input.asp"][/URL]
It retrieves prices from an access database.
The form can give you a price TO or FROM any of the five airports listed.
For example, if you choose:
Heathrow Airport to London Euston - it gives you a price
If you choose:
SW1 to Gatwick Airport - it gives you a price
etc, etc
The form DOES NOT give you a price if neither the pickup nor dropoff is any of the five airports listed. That's fine.
So if you choose:
London Euston to SW1 - it gives an error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
/02process.asp, line 63
I simply want to display a snippet of text saying 'No Record Found'. Whenever the form cannot locate a matching record I want this message displayed. I can then adjust that section of the HTML accordingly.
As an added bonus, I have used several SQL statements. The code works fine but if anybody can suggest a more efficient way doing it then feel free.
Thank you all. My full ASP code is below:
http://londonheathrowcars.com/01input.asp"][/URL]
It retrieves prices from an access database.
The form can give you a price TO or FROM any of the five airports listed.
For example, if you choose:
Heathrow Airport to London Euston - it gives you a price
If you choose:
SW1 to Gatwick Airport - it gives you a price
etc, etc
The form DOES NOT give you a price if neither the pickup nor dropoff is any of the five airports listed. That's fine.
So if you choose:
London Euston to SW1 - it gives an error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
/02process.asp, line 63
I simply want to display a snippet of text saying 'No Record Found'. Whenever the form cannot locate a matching record I want this message displayed. I can then adjust that section of the HTML accordingly.
As an added bonus, I have used several SQL statements. The code works fine but if anybody can suggest a more efficient way doing it then feel free.
Thank you all. My full ASP code is below:
Code:
<%
sTempVar = "&#"
pickup = request.form("frm-pick")
dropoff = request.form("frm-drop")
set myconn = Server.CreateObject("ADODB.connection")
connection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &_
Server.MapPath("x-db.mdb") & ";"
myconn.open (connection)
set rs=Server.CreateObject("ADODB.recordset")
If pickup = "Heathrow Airport" Then
rs.Open "SELECT tbllhr.postcode, tbllhr.salbrnz, tbllhr.salsilv, tbllhr.salgold, tbllhr.estbrnz, tbllhr.mpvbrnz, tbllhr.mpvsilv, tbllhr.vanbrnz, tbllhr.vansilv FROM tbllhr WHERE tbllhr.postcode = '" & dropoff & "' ", myconn
ElseIf dropoff = "Heathrow Airport" Then
rs.Open "SELECT tbllhr.postcode, tbllhr.salbrnz, tbllhr.salsilv, tbllhr.salgold, tbllhr.estbrnz, tbllhr.mpvbrnz, tbllhr.mpvsilv, tbllhr.vanbrnz, tbllhr.vansilv FROM tbllhr WHERE tbllhr.postcode = '" & pickup & "' ", myconn
ElseIf pickup = "Gatwick Airport" Then
rs.Open "SELECT tbllgw.postcode, tbllgw.salbrnz, tbllgw.salsilv, tbllgw.salgold, tbllgw.estbrnz, tbllgw.mpvbrnz, tbllgw.mpvsilv, tbllgw.vanbrnz, tbllgw.vansilv FROM tbllgw WHERE tbllgw.postcode = '" & dropoff & "' ", myconn
ElseIf dropoff = "Gatwick Airport" Then
rs.Open "SELECT tbllgw.postcode, tbllgw.salbrnz, tbllgw.salsilv, tbllgw.salgold, tbllgw.estbrnz, tbllgw.mpvbrnz, tbllgw.mpvsilv, tbllgw.vanbrnz, tbllgw.vansilv FROM tbllgw WHERE tbllgw.postcode = '" & pickup & "' ", myconn
ElseIf pickup = "Stansted Airport" Then
rs.Open "SELECT tblstn.postcode, tblstn.salbrnz, tblstn.salsilv, tblstn.salgold, tblstn.estbrnz, tblstn.mpvbrnz, tblstn.mpvsilv, tblstn.vanbrnz, tblstn.vansilv FROM tblstn WHERE tblstn.postcode = '" & dropoff & "' ", myconn
ElseIf dropoff = "Stansted Airport" Then
rs.Open "SELECT tblstn.postcode, tblstn.salbrnz, tblstn.salsilv, tblstn.salgold, tblstn.estbrnz, tblstn.mpvbrnz, tblstn.mpvsilv, tblstn.vanbrnz, tblstn.vansilv FROM tblstn WHERE tblstn.postcode = '" & pickup & "' ", myconn
ElseIf pickup = "Luton Airport" Then
rs.Open "SELECT tblltn.postcode, tblltn.salbrnz, tblltn.salsilv, tblltn.salgold, tblltn.estbrnz, tblltn.mpvbrnz, tblltn.mpvsilv, tblltn.vanbrnz, tblltn.vansilv FROM tblltn WHERE tblltn.postcode = '" & dropoff & "' ", myconn
ElseIf dropoff = "Luton Airport" Then
rs.Open "SELECT tblltn.postcode, tblltn.salbrnz, tblltn.salsilv, tblltn.salgold, tblltn.estbrnz, tblltn.mpvbrnz, tblltn.mpvsilv, tblltn.vanbrnz, tblltn.vansilv FROM tblltn WHERE tblltn.postcode = '" & pickup & "' ", myconn
ElseIf pickup = "London City Airport" Then
rs.Open "SELECT tbllcy.postcode, tbllcy.salbrnz, tbllcy.salsilv, tbllcy.salgold, tbllcy.estbrnz, tbllcy.mpvbrnz, tbllcy.mpvsilv, tbllcy.vanbrnz, tbllcy.vansilv FROM tbllcy WHERE tbllcy.postcode = '" & dropoff & "' ", myconn
ElseIf dropoff = "London City Airport" Then
rs.Open "SELECT tbllcy.postcode, tbllcy.salbrnz, tbllcy.salsilv, tbllcy.salgold, tbllcy.estbrnz, tbllcy.mpvbrnz, tbllcy.mpvsilv, tbllcy.vanbrnz, tbllcy.vansilv FROM tbllcy WHERE tbllcy.postcode = '" & pickup & "' ", myconn
End If
%>
<!--HTML START -->
<h1><%=pickup%> to <%=dropoff%></h1>
<p>SB: <%=sTempVar & "163;" & trim(rs("salbrnz"))%></p>
<p>SS: <%=sTempVar & "163;" & trim(rs("salsilv"))%></p>
<p>SG: <%=sTempVar & "163;" & trim(rs("salgold"))%></p>
<p>EB: <%=sTempVar & "163;" & trim(rs("estbrnz"))%></p>
<p>MB: <%=sTempVar & "163;" & trim(rs("mpvbrnz"))%></p>
<p>MS: <%=sTempVar & "163;" & trim(rs("mpvsilv"))%></p>
<p>VB: <%=sTempVar & "163;" & trim(rs("vanbrnz"))%></p>
<p>VS: <%=sTempVar & "163;" & trim(rs("vansilv"))%></p>
<!--HTML FINISH -->
<%
rs.Close
Set rs = Nothing
myconn.Close
Set myconn = Nothing
%>