<% Option Explicit Response.Expires = 60 Response.Expiresabsolute = Now() - 1 Response.AddHeader "pragma","no-cache" Response.AddHeader "cache-control","private" Response.CacheControl = "no-cache" ' Declare our variables... always good practice! on error resume next Dim strURL ' The URL of this page so the form will work ' no matter what this file is named. Dim Total Dim cnnSearch ' ADO connection Dim rstSearch ' ADO recordset Dim strDBPath ' path to our Access database (*.mdb) file Dim strSQL ' The SQL Query we build on the fly Dim strSearch ' The text being looked for ' Retreive the URL of this page from Server Variables strURL = Request.ServerVariables("URL") ' Retreive the term being searched for. I'm doing it on ' the QS since that allows people to bookmark results. ' You could just as easily have used the form collection. strSearch = Request.QueryString("search") strSearch = Replace(strSearch, "'", "''") ' Since I'm doing this all in one page I need to see if anyone ' has searched for something. If they have we hit the DB. ' O/W I just show the search form and quit. %>


'Search' The Owner's List
by Name, City, State and Color & VIN (% returns all)
Beta Ver. 1.2  (By founder Dave Wagner - 03Mach1)

  

QUICK SEARCH BY COLOR (Click on Color)
( Blue, Zinc Yellow, Screamin'  Yellow, Torch Red, BLACK, Dark Shadow Grey - DSG, White, Comp. Orange)

Example: Type in 'Azure Blue%' for Color, 'OH' for OHIO, 5-Speed, Auto, etc...,
USE '%' for Wildcards, LA% = anything that starts with LA... %Z1%, Find 'Z1' anywhere...etc
NOTE: It may give you More than you are looking for, just narrow your search.

<% If strSearch <> "" Then ' MapPath of virtual database file path to a physical path. ' If you want you could hard code a physical path here. 'strDBPath = Server.MapPath("database.mdb") buffer=true strDBPath="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("/database/register1.mdb") 'define the query strQuery = "SELECT ID, Name,City,State,Year, Exterior_Color,InteriorUpgrade,Transmission,date_ordered,vin FROM MachOwnersList " ' Create an ADO Connection to connect to the sample database. ' We're using OLE DB but you could just as easily use ODBC or a DSN. Set cnnSearch = Server.CreateObject("ADODB.Connection") ' This line is for the Access sample database: cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";" ' Build our query based on the input. strSQL = "SELECT ID, Name, City, State, Year, InteriorUpgrade, Exterior_Color, Transmission, vin " _ & "FROM MachOwnersList " _ & "WHERE City LIKE '" & Replace(strSearch, "'", "''") & "' " _ & "OR State LIKE '" & Replace(strSearch, "'", "''") & "' " _ & "OR Exterior_Color LIKE '%" & Replace(strSearch, "'", "''") & "' " _ & "OR Name LIKE '" & Replace(strSearch, "'", "''") & "' " _ & "OR Transmission LIKE '" & Replace(strSearch, "'", "''") & "' " _ & "OR vin LIKE '" & Replace(strSearch, "'", "''") & "' " _ & "ORDER BY ID" ' Execute our query using the connection object. It automatically ' creates and returns a recordset which we store in our variable. Set rstSearch = cnnSearch.Execute(strSQL) ' Display a table of the data in the recordset. We loop through the ' recordset displaying the fields from the table and using MoveNext ' to increment to the next record. We stop when we reach EOF. ' For fun I'm combining some fields and showwing you can do more then ' just spit out the data in the form it is in in the table. %>
<% total=0 Do While Not rstSearch.EOF %> <% Total=total+1 rstSearch.MoveNext response.flush Loop %>
Member
ID
Name City State Year Color Trans vin
<%= rstSearch.Fields("ID").Value %>  <%= rstSearch.Fields("Name").Value %>  <%= rstSearch.Fields("city").Value %>  <%= rstSearch.Fields("state").Value %>  <%= rstSearch.Fields("year").Value %>  <%= rstSearch.Fields("Exterior_Color").Value %>  <%= rstSearch.Fields("Transmission").Value %>  <%= rstSearch.Fields("vin").Value %> 

Total: <%Response.write Total%>

RETURN TO TOP OF PAGE

Back to Owner's Page
ORDER MACH 1 PARTS ONLINE:

<% ' Close our recordset and connection and dispose of the objects rstSearch.Close Set rstSearch = Nothing cnnSearch.Close Set cnnSearch = Nothing End If %>