01.
<%
Option
Explicit %>
02.
<html>
03.
<head>
04.
<title>ThaiCreate.Com ASP & Microsoft Access Tutorial</title>
05.
</head>
06.
<body>
07.
<form name=
"frmSearch"
method=
"get"
action=
"<%=Request.ServerVariables("
SCRIPT_NAME
")%>"
>
08.
<table width=
"599"
border=
"1"
>
09.
<tr>
10.
<th>Keyword
11.
<input name=
"txtKeyword"
type=
"text"
id=
"txtKeyword"
value=
"<%=Request.QueryString("
txtKeyword
")%>"
>
12.
<input type=
"submit"
value=
"Search"
></th>
13.
</tr>
14.
</table>
15.
</form>
16.
<%
17.
if Request.QueryString(
"txtKeyword"
) <>
""
Then
18.
Dim
Conn,strSQL,objRec
19.
Set
Conn = Server.Createobject(
"ADODB.Connection"
)
20.
Conn.Open
"DRIVER=Microsoft Access Driver (*.mdb);DBQ="
& Server.MapPath(
"mydatabase.mdb"
),
""
,
""
21.
22.
strSQL =
"SELECT * FROM customer "
23.
strSQL = strSQL &
"WHERE (Name LIKE '%"
& Request.QueryString(
"txtKeyword"
) &
"%' "
24.
strSQL = strSQL &
"or Email LIKE '%"
& Request.QueryString(
"txtKeyword"
) &
"%' ) "
25.
Set
objRec = Server.CreateObject(
"ADODB.Recordset"
)
26.
objRec.Open strSQL, Conn, 1,3
27.
%>
28.
<table width=
"600"
border=
"1"
>
29.
<tr>
30.
<th width=
"91"
> <div align=
"center"
>CustomerID </div></th>
31.
<th width=
"98"
> <div align=
"center"
>Name </div></th>
32.
<th width=
"198"
> <div align=
"center"
>Email </div></th>
33.
<th width=
"97"
> <div align=
"center"
>CountryCode </div></th>
34.
<th width=
"59"
> <div align=
"center"
>Budget </div></th>
35.
<th width=
"71"
> <div align=
"center"
>Used </div></th>
36.
</tr>
37.
<%
38.
While
Not
objRec.EOF
39.
%>
40.
<tr>
41.
<td><div align=
"center"
><%=objRec.Fields(
"CustomerID"
).Value%></div></td>
42.
<td><%=objRec.Fields(
"Name"
).Value%></td>
43.
<td><%=objRec.Fields(
"Email"
).Value%></td>
44.
<td><div align=
"center"
><%=objRec.Fields(
"CountryCode"
).Value%></div></td>
45.
<td align=
"right"
><%=objRec.Fields(
"Budget"
).Value%></td>
46.
<td align=
"right"
><%=objRec.Fields(
"Used"
).Value%></td>
47.
</tr>
48.
<%
49.
objRec.MoveNext
50.
Wend
51.
%>
52.
</table>
53.
<%
54.
objRec.Close()
55.
Conn.Close()
56.
Set
objRec =
Nothing
57.
Set
Conn =
Nothing
58.
End
IF
59.
%>
60.
</body>
61.
</html>