Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Beginner
Dec 1, 1999

Add Full-Text Search of an Access Database to ASP Pages

Although SQL Server 7 is the more robust and scalable database for full-text searching, many developers still use Microsoft Access for less-demanding database applications. You can search an Access database if you concatenate the field names in your query.

For example, in the following ASP code, the SQL query combines the FirstName and LastName fields, uses the keyword LIKE and then wraps the search fragment in wildcard characters. When run against the NorthWind database, this query produces a recordset of all employees with the letters "an" in their names.

 
<%@ Language=VBScript %>
<HTML>
<HEAD>
</HEAD>
<BODY>
<!--#include File="adovbs.inc"-->
<%
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.Open Application("Connection5_ConnectionString")
rs.CursorType = adOpenStatic
rs.LockType = adLockReadOnly
rs.CursorLocation = adUseClient
Set rs.ActiveConnection = conn
rs.Source = "SELECT * FROM Employees WHERE FirstName + Lastname LIKE '%an%'"
rs.Open
Do While Not rs.EOF
   Response.Write rs("FirstName") & " " & rs("LastName") & "<br>"
   rs.MoveNext
Loop
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
%>
</BODY>
</HTML>
Ken Cox
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap