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.
18.
19.
20.
Dim Conn,strSQL,objRec
21.
Set Conn = Server.Createobject(
"ADODB.Connection"
)
22.
Conn.Open
"DRIVER=Microsoft Access Driver (*.mdb);DBQ="
& Server.MapPath(
"mydatabase.mdb"
),
""
,
""
23.
'*** Search By Name or Email ***'
24.
strSQL =
"SELECT * FROM customer "
25.
26.
if
Request.QueryString(
"txtKeyword"
) <>
""
Then
27.
strSQL = strSQL &
"WHERE (Name LIKE '%"
& Request.QueryString(
"txtKeyword"
) &
"%' "
28.
strSQL = strSQL &
"or Email LIKE '%"
& Request.QueryString(
"txtKeyword"
) &
"%' ) "
29.
End
IF
30.
31.
Set objRec = Server.CreateObject(
"ADODB.Recordset"
)
32.
objRec.Open strSQL, Conn, 1,3
33.
%>
34.
<table width=
"600"
border=
"1"
>
35.
<tr>
36.
<th width=
"91"
> <div align=
"center"
>CustomerID </div></th>
37.
<th width=
"98"
> <div align=
"center"
>Name </div></th>
38.
<th width=
"198"
> <div align=
"center"
>Email </div></th>
39.
<th width=
"97"
> <div align=
"center"
>CountryCode </div></th>
40.
<th width=
"59"
> <div align=
"center"
>Budget </div></th>
41.
<th width=
"71"
> <div align=
"center"
>Used </div></th>
42.
</tr>
43.
<%
44.
While Not objRec.EOF
45.
%>
46.
<tr>
47.
<td><div align=
"center"
><%=objRec.Fields(
"CustomerID"
).Value%></div></td>
48.
<td><%=objRec.Fields(
"Name"
).Value%></td>
49.
<td><%=objRec.Fields(
"Email"
).Value%></td>
50.
<td><div align=
"center"
><%=objRec.Fields(
"CountryCode"
).Value%></div></td>
51.
<td align=
"right"
><%=objRec.Fields(
"Budget"
).Value%></td>
52.
<td align=
"right"
><%=objRec.Fields(
"Used"
).Value%></td>
53.
</tr>
54.
<%
55.
objRec.MoveNext
56.
Wend
57.
%>
58.
</table>
59.
<%
60.
objRec.Close()
61.
Conn.Close()
62.
Set objRec = Nothing
63.
Set Conn = Nothing
64.
%>
65.
</body>
66.
</html>