|
<%@ language="VBScript" %>
<%
Option Explicit
Dim searchWord
dim mphone
Dim primaryKey
Dim alternateKey
Dim strDbPath
Dim oFS
Dim oConn
Dim oRS
searchWord = Trim(Request.QueryString("searchWord"))
if Len(searchWord) = 0 then
Response.Redirect("search.htm")
end if
set mphone = Server.CreateObject("MetaphoneCOM.DoubleMetaphoneShort")
mphone.ComputeMetaphoneKeysScr searchWord, primaryKey, alternateKey
strDbPath = Server.MapPath("/ASPWordDBLookup") & "\..\namelist.mdb"
'Make sure database is accessible
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
if not oFS.FileExists(strDbPath) then
response.write "Access database " & strDbPath & " does not exist."
Response.End
end if
on error resume next
oFS.OpenTextFile strDbPath
if err.number <> 0 then
response.write "Error opening database: " & err.description & "<br>Make sure IUSR_" & Request.ServerVariables("SERVER_NAME") & " has Full Control on " & strDbPath & " and its containing folder"
Response.End
end if
on error goto 0
'Use the namelist.mdb Access database in the parent directory
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDbPath
oConn.Open
Dim strSql
'Select from the Words table, which contains a list of names, and the
'unsigned short representation of their Double Metaphone keys
strSql = "select word from Words where"
strSql = strSql & "(key1 = " & primaryKey & ")"
strSql = strSql & " or (key2 = " & primaryKey & ")"
If alternateKey <> -1 Then
strSql = strSql & " or (key1 = " & alternateKey & ")"
strSql = strSql & " or (key2 = " & alternateKey & ")"
End If
set oRS = oConn.Execute(strSql)
%>
<html>
<head>
<title>ASP Word DB Lookup</title>
</head>
<body>
Names matching '<%= searchWord %>'
<ul>
<%
while Not oRS.EOF
%><li><%= oRS("word") %>
<%
oRS.MoveNext
wend
oConn.Close
%>
</ul>
</form>
<p>
<a href="search.htm">Back</a>
</body>
</html>
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
My name is Adam Nelson. I've been a professional programmer since 1996, working on everything from database development, early first-generation web applications, modern n-tier distributed apps, high-performance wireless security tools, to my last job as a Senior Consultant at BearingPoint posted in Baghdad, Iraq training Iraqi developers in the wonders of C# and ASP.NET. I am currently an Engineering Director at Dell.
I have a wide range of skills and interests, including cryptography, image processing, computational linguistics, military history, 3D graphics, database optimization, and mathematics, to name a few.