<%
SearchType = GetInput("SearchType")
SearchScope = GetInput("SearchScope")
SearchPhrase = GetInput("SearchPhrase")
If (SearchType = "") OR (SearchScope = "") OR (SearchPhrase = "") Then
Response.Write("This section is searchable by Contact Last Name, Institution, Keyword, or Country.")
Call DrawForm()
Else
Call DrawForm()
Call Search()
Call DrawForm()
End If
Sub DrawForm()
Response.Write("")
End Sub
Sub Search()
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open Application("DSN_International")
Select Case SearchScope
Case 1
Select Case SearchType
Case "Keyword"
Set RS = Conn.Execute("EXEC spSearchKeywords '%" & SearchPhrase & "%'")
Case "Contact Last Name"
Set RS = Conn.Execute("EXEC spSearchLastNames '%" & SearchPhrase & "%'")
Case "Institution"
Set RS = Conn.Execute("EXEC spSearchInstitutions '%" & SearchPhrase & "%'")
Case "Country"
Set RS = Conn.Execute("EXEC spSearchCountries '%" & SearchPhrase & "%'")
End Select
Case Else
Select Case SearchType
Case "Keyword"
Set RS = Conn.Execute("EXEC spSearchKeywords '" & SearchPhrase & "'")
Case "Contact Last Name"
Set RS = Conn.Execute("EXEC spSearchLastNames '" & SearchPhrase & "'")
Case "Institution"
Set RS = Conn.Execute("EXEC spSearchInstitutions '" & SearchPhrase & "'")
Case "Country"
Set RS = Conn.Execute("EXEC spSearchCountries '" & SearchPhrase & "'")
End Select
End Select
If Not RS.EOF Then
Response.Write("Below are the matches for your search. Click on one to get more detail.")
Response.Write("")
While Not RS.EOF
Citation = ""
Set RSCitation = Conn.Execute("EXEC spGetCitation " & RS("ProjectID"))
Set RSCountries = Conn.Execute("EXEC spGetCountries " & RS("ProjectID"))
While Not RSCountries.EOF
Citation = Citation & Replace(RSCountries("Country"), SearchPhrase, "" & SearchPhrase & "")
Set RSProvinces = Conn.Execute("EXEC spGetProvinces " & RS("ProjectID") & ",'" & RSCountries("Country") & "'")
If Not RSProvinces.EOF Then
Citation = Citation & "("
End If
While Not RSProvinces.EOF
Citation = Citation & RSProvinces("Province")
RSProvinces.MoveNext
If RSProvinces.EOF Then
Citation = Citation & ")"
Else
Citation = Citation & ", "
End If
WEnd
RSCountries.MoveNext
If Not RSCountries.EOF Then
Citation = Citation & ", "
End If
WEnd
Citation = Citation & "; " & RSCitation("Title")
Response.Write("- " & Citation & "
")
RS.MoveNext
WEnd
Response.Write("
")
Else
Response.Write("No matches were found. Try to revise your search or use the browse function to manually search.")
End If
End Sub
Private Function SQLEncode(SQLEncodeValue)
For LCV = 1 to Len(SQLEncodeValue)
Select Case Mid(SQLEncodeValue, LCV, 1)
Case "'"
SQLEncode = SQLEncode & "'"
SQLEncode = SQLEncode & Mid(SQLEncodeValue, LCV, 1)
Case Else
SQLEncode = SQLEncode & Mid(SQLEncodeValue, LCV, 1)
End Select
Next
End Function
Private Function InsertValue(Value)
If Value = "" Then
InsertValue = ""
Else
InsertValue = " VALUE=""" & Server.HTMLEncode(Value) & """"
End If
End Function
Private Function InsertSelected(Value1, Value2)
If Value1 <> Value2 Then
InsertSelected = ""
Else
InsertSelected = " SELECTED"
End If
End Function
Private Function GetInput(Variable)
GetInput = Trim(Request.Form(Variable))
If Trim(Request.QueryString(Variable)) <> "" Then
GetInput = Trim(Request.QueryString(Variable))
End If
End Function
%>