<%@ LANGUAGE="VBSCRIPT"%> <% Option Explicit 'Response.Expires = 0 %> <% Const datasource = "d:\websites\www.airshows.com\files\data\airshows.mdb" Const BACKGRD = "" Dim dcDB Dim dcRS Dim cmdDB Dim stype Dim sstate Dim smonth Dim msgresponse Dim action Dim strQuery Dim curdate Const AHREF = " Airshow Search Results <% Response.Write BACKGRD If Request.ServerVariables("CONTENT_LENGTH") = 0 or Request.ServerVariables("REQUEST_METHOD") = "GET" Then 'Response.Write "Get" 'msgresponse = "Database Management Started" stype = Trim(Request.QueryString("type")) 'Response.Write stype Set dcDB = Open_Conn() Create_Sql(stype) 'Response. Write sql_1 & "
" Set dcRS = Server.CreateObject("ADODB.Recordset") dcRS.Open sql_1, dcDB, adOpenStatic, adLockReadOnly 'dcRS.MoveFirst If Not dcRS.EOF Then 'Response.Write "Run Records
" If stype = "performers" Then write_results 0, 1 Else write_results 1, 1 End If dcRS.Close Set dcRS = Nothing Elseif dcRS.EOF Then If stype = "performers" Then write_results 0, 0 Else write_results 1, 0 End If 'Response.Write "No Records
" End If dcDB.Close 'Response.Write " Closed DB
" Set dcDB = Nothing ElseIf Request.ServerVariables("REQUEST_METHOD") = "POST" Then 'Response.Write "Post " & action smonth = Request.Form("bymonth") sstate = Request.Form("bystate") stype = Trim(Request.QueryString("type")) 'Response.Write stype If stype = "usa" Then If sstate = "" and smonth = "" Then stype = "usalist" Else stype = "msusa" End If ElseIf stype = "intl" Then If smonth = "" Then stype = "intllist" Else stype = "msintl" End If End If 'Response.Write stype 'Response.Write smonth & " " & sstate Set dcDB = Open_Conn() Create_Sql(stype) 'Response.Write sql_1 & "
" Set dcRS = Server.CreateObject("ADODB.Recordset") dcRS.Open sql_1, dcDB, adOpenStatic, adLockReadOnly 'dcRS.MoveFirst If Not dcRS.EOF Then 'Response.Write "Run Records
" write_results 1, 1 dcRS.Close Set dcRS = Nothing ElseIf dcRS.EOF Then 'Response.Write "No Records
" write_results 1, 0 End If dcDB.Close 'Response.Write " Closed DB
" Set dcDB = Nothing Else 'this shouldn't happen end this Response.End End if 'Open Connection to Database Function Open_Conn() Dim dcnDB Set dcnDB = Server.CreateObject("ADODB.Connection") 'Response.Write ("Try to Open Connection") & "
" dcnDB.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & datasource If dcnDB.Errors.Count > 0 Then 'Errors have occurred so we can write them out 'For Each Error In dcnDB.Errors ' Response.Write Error.Number & ": " & Error.Description 'Next dcnDB.Close Set dcnDB = Nothing 'Response.Write("Failed To Connect to Database") Response.End End If 'Response.Write "Opened DB
" Set Open_Conn = dcnDB End Function Sub Create_Sql(mode) If mode = "msusa" Then If smonth <> "" Then smonth = smonth & "%" smonth = """" & smonth & """" End If If sstate <> "" Then sstate = sstate & "%" sstate = """" & sstate & """" End If If smonth <> "" And sstate <> "" Then Sql_1 = "SELECT * From Airshows Where ((Airshows.Country = ""USA"") And (Airshows.Month Like " & smonth & ") And (Airshows.State Like " & sstate & ")) ORDER BY Airshows.Name, Airshows.StartDate ASC;" Sort_Mode = 3 ElseIf smonth = "" And sstate <> "" Then Sql_1 = "SELECT * From Airshows Where ((Airshows.Country = ""USA"") And (Airshows.State Like " & sstate & ")) ORDER BY Airshows.Name, Airshows.StartDate ASC;" Sort_Mode = 2 ElseIf smonth <> "" And sstate = "" Then Sql_1 = "SELECT * From Airshows Where ((Airshows.Country = ""USA"") And (Airshows.Month Like " & smonth & ")) ORDER BY Airshows.Name, Airshows.StartDate ASC;" Sort_Mode = 1 ElseIf smonth = "" And sstate = "" Then Response.End End If ElseIf mode = "usalist" Then Sql_1 = "SELECT * From Airshows Where Airshows.Country = ""USA"" ORDER BY Airshows.Name, Airshows.StartDate ASC;" ElseIf mode = "usapresent" Then Sql_1 = "SELECT * From Airshows Where (Airshows.Country = ""USA"" And Airshows.StartDate >= #" & Now & "#) ORDER BY Airshows.Name, Airshows.StartDate ASC;" ElseIf mode = "performers" Then Sql_1 = "SELECT * From Performers;" ElseIf mode = "msintl" Then If smonth <> "" Then smonth = smonth & "%" smonth = """" & smonth & """" Sql_1 = "SELECT * From Airshows Where ((Airshows.Country <> ""USA"") And (Airshows.Month Like " & smonth & ")) ORDER BY Airshows.Name, Airshows.StartDate ASC;" End If ElseIf mode = "intlpresent" Then Sql_1 = "SELECT * From Airshows Where ((Airshows.Country <> ""USA"") And (Airshows.StartDate >= #" & Now & "#)) ORDER BY Airshows.Name, Airshows.StartDate ASC;" ElseIf mode = "intllist" Then Sql_1 = "SELECT * From Airshows Where Airshows.Country <> ""USA"" ORDER BY Airshows.Name, Airshows.StartDate ASC;" Else Response.End End If 'Response. Write sql_1 & "
" End Sub Sub write_results(mtype, mode) If mtype = 1 Then If stype = "usa" or stype = "usalist" or stype = "usapresent" or stype = "msusa" then Response.Write ("

List of United States Airshows

") ElseIf stype = "msintl" or stype = "intllist" or stype = "intlpresent" Then Response.Write ("

List of International Airshows

") End If Response.Write ("
") Response.Write ("
") Response.Write ("") Response.Write ("") Response.Write ("") If stype = "usa" or stype = "usalist" or stype = "usapresent" or stype = "msusa" then Response.Write ("") ElseIf stype = "msintl" or stype = "intllist" or stype = "intlpresent" Then Response.Write ("") End If Response.Write ("") Response.Write ("") Response.Write ("") If mode = 1 Then Do Until dcRS.EOF Response.Write ("") If dcRS("Html") <> "" Then Response.Write ("") Else Response.Write ("") End If If stype = "usa" or stype = "usalist" or stype = "usapresent" or stype = "msusa" then Response.Write ("") ElseIf stype = "msintl" or stype = "intllist" or stype = "intlpresent" Then Response.Write ("") End If Response.Write ("") Response.Write ("") Response.Write ("") dcRS.MoveNext Loop ElseIf mode = 0 Then Response.Write ("") Response.Write ("") Response.Write ("") Response.Write ("") Response.Write ("") Response.Write ("") End If Response.Write ("
______City/Place_______________State______________Country__________First Day________Last Day____
" & AHREF & dcRS("Html") & """ target=""_blank"">" & dcRS("Name") & " " & dcRS("Name") & " " & dcRS("State") & " " & dcRS("Country") & " " & FormatDateTime(dcRS("StartDate"), vbShortDate) & " " & FormatDateTime(dcRS("EndDate"), vbShortDate) & "
" & " " & "No Airshows Found" & " " & "
") Response.Write ("
") ElseIf mtype = 0 Then Response.Write ("

List of Airshow Performers

") Response.Write ("
") Response.Write ("
") Response.Write ("") Response.Write ("") Response.Write ("") If mode = 1 Then Do Until dcRS.EOF Response.Write ("") If dcRS("Html") <> "" Then Response.Write ("") Else Response.Write ("") End If Response.Write ("") dcRS.MoveNext Loop End If Response.Write ("
__Name of Performer__
" & AHREF & dcRS("Html") & """ target=""_blank"">" & dcRS("Name") & " " & dcRS("Name") & "
") Response.Write ("
") End If End Sub If stype = "usa" or stype = "usalist" or stype = "usapresent" or stype = "msusa" Then Response.Write "

Return to:

" ElseIf stype = "msintl" or stype = "intllist" or stype = "intlpresent" Then Response.Write "

Return to:

" Else Response.Write "

" End If %>