%
Option Explicit
If adCmdText = "" Then
Const adOpenStatic = 3
Const adCmdText = &H0001
End If
Response.Buffer = True
Dim objRS,strSQL,strSQLWhere,strSQLOrderBy,strSQLSelect
Dim arrData, strCustomerName , strAddress1,strCity, strEmailAddress ,strPhoneNumber,strFax ,strZip
Dim intcolcounter,introwcounter
dim strBacCol, intPC,intRecToShow,intSampleSize,intHeader
%>
Speedy Wheels Dealer locator
<%
'---------------------------------------------
'Main
'---------------------------------------------
call SetVars
call DrawForm
call CheckForm
call CreateSQL
call GetData
call DrawOutput
Response.End()
'--------------------------------------------------------
'Sub SetVars
'--------------------------------------------------------
sub SetVars
intPC = request("pc")
intHeader = request("header")
if intHeader = "" then
intHeader = "1"
end if
intRecToShow = 30
intSampleSize=100
end sub
'--------------------------------------------------------
'Sub DrawForm
'--------------------------------------------------------
Sub DrawForm
%>
<%
end sub
'--------------------------------------------------------
'Sub CheckForm
'--------------------------------------------------------
Sub CheckForm
%>
<%
if intPC = "" then
%>
Please
enter your postcode to find a dealer in your area.
<%
response.end
end if
if Len(intPC) >4 or Len(intPC) <3 then
%>
Please
enter a valid Poscode to search on
<%
response.end
end if
%>
<%
end sub
'--------------------------------------------------------
'Sub CreateSQL
'--------------------------------------------------------
Sub CreateSQL
strSQLSelect = "SELECT TOP " & intRecToShow & " [Customer Name]," & _
" [Address 1]," & _
" City," & _
" [Email Address]," & _
" [Phone Number]," & _
" Fax," & _
" Zip" & _
" From CustomerFile.csv"
strSQLWhere=" WHERE (((Zip) Between (" & intPC & "-"& intSampleSize &") And (" & intPC & "+"& intSampleSize &")))"
strSQLOrderBy =" ORDER BY Abs([Zip]-" & intPC & "), City"
strSQL = strSQLSelect & " " & strSQLWhere & " " & strSQLOrderBy
end sub
'--------------------------------------------------------
'Sub GetData
'--------------------------------------------------------
Sub GetData
%>
<%
Set objRS = objConn.Execute(strSQL,,adCmdText)
If objRS.eof Then
objRS.close
set objRS=nothing
objConn.close
set objConn=nothing
call sNoRecord
response.end
End If
arrData = objRS.getrows
objRS.close
set objRS = nothing
objConn.close
set objConn = nothing
end sub
'--------------------------------------------------------
'Sub DrawOutput
'--------------------------------------------------------
Sub DrawOutput
%>
| Dealer
Name |
Address |
City |
Postcode |
Phone |
Email |
<%
For intRowCounter= 0 to UBound(arrData,2)
%>
<%
strCustomerName = arrData(0,introwcounter)
strAddress1 = arrData(1,introwcounter)
strCity = arrData(2,introwcounter)
strEmailAddress = arrData(3,introwcounter)
strPhoneNumber= arrData(4,introwcounter)
strFax = arrData(5,introwcounter)
strZip = arrData(6,introwcounter)
If introwcounter Mod 2 then
strBacCol="#CCCCCC"
else
strBacCol="#FFFFFF"
end if
%>
>
| <%= strCustomerName %> |
<%= strAddress1 %> |
<%= strCity %> |
<%= strZip %> |
<%= strPhoneNumber %> |
<%
If strEmailAddress <> "" then
response.Write("Email")
else
response.Write("N/A")
end if
%> |
<%
Next
%>
<%
end sub
'----------------------------
'Sub No Record
'----------------------------------
Sub sNoRecord
%>
No
items currently match your search.
Choose
a different Postcode
|
<%
end sub
%>