Hello Experts,
I am a newbie to ASP and am looking for some code that will do a search of my Access database on multiple fields and send a display to the screen.
Here is part of one of my pages that is currently working. All I need now to it add the search to pull out the exact display the ASP is currently pulling data.
I need to search fields: ZipCode, Keywords, Category, and SubCategory
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsResource 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
Dim Prevcolor 'holds the previous color
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB
.Connectio
n")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("KellyResou
rce.mdb")
'Create an ADO recordset object
Set rsResource = Server.CreateObject("ADODB
.Recordset
")
'Initialise the strSQL variable with an SQL statement to query the database
strSQL ="SELECT DataList.Category, DataList.SubCategory, DataList.Organization, DataList.Website, DataList.Description, DataList.City, DataList.State, Datalist.phone FROM DataList WHERE (((DataList.Category)=1) AND ((DataList.SubCategory)Is Null));"
'Open the recordset with the SQL query
rsResource.Open strSQL, adoCon
'Loop through the recordset
Do While not rsResource.EOF
'Write the HTML to display the current record in the recordset
response.write "<table width=100% border=1 cellpadding=1 ><tr>"
recordnumber=1
rownumber=1
prevcolor="white"
Do While not rsResource.EOF
if rownumber mod 2=0 and recordnumber mod 2=0 then
response.write "<td width=50% bgcolor=white>"
else
if rownumber mod 2=0 and recordnumber mod 2<>0 then
response.write "<td width=50% bgcolor=#99cc99>"
else
if rownumber mod 2<>0 and recordnumber mod 2<>0 then
response.write "<td width=50% bgcolor=white>"
else
response.write "<td width=50% bgcolor=#99cc99>"
end if
end if
end if
If isnull(rsResource("website
")) then
response.write(rsresource(
"Phone"))
else%>
<a href="
http://<%Response.Wr
ite (rsResource("Website"))%>"
><%Respons
e.Write (rsResource("Website"))%><
/a>
<%end if%>
<%Response.Write ("<BR>")
Response.Write (rsResource("Description")
)
Response.Write ("<BR>")
Response.Write (rsResource("City"))
Response.Write (", ")
Response.Write (rsResource("state"))
Response.Write ("<BR>")
Response.Write (rsResource("Organization"
))
Response.Write ("<BR>")
response.write "</td>"
if recordnumber mod 2=0 Then ' if the record number is divisible by two, start a new row
response.write "</tr><tr>"
rownumber=rownumber +1
end if
recordnumber=recordnumber + 1
'Move to the next record in the recordset
rsResource.MoveNext
Loop
response.write "</tr></table>"
Loop
'Reset server objects
rsResource.Close
Set rsResource = Nothing
Set adoCon = Nothing
%>
Thanks for your help. I don't know where to start on this.