-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsearch.asp
executable file
·68 lines (56 loc) · 1.57 KB
/
search.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<html>
<body>
<table align="left" border="0" width="200">
<tr>
<td align="center">
<font size="20">MBA</font><br>
My Bad Application
</td>
</tr>
<tr>
<td align="center">
<a href="/search.asp">Employee Search</a>
</td>
</tr>
</table>
<Br><Br><Br><Br><Br><Br>
<table border="0" width="200">
<tr>
<td align="left"><br><br>
<h3>Employee Search</h3>
<form action="" method="GET" name="searchform">
<input type="text" name="search" id="search">
<input type="submit" value="Search">
</form>
<%
'Sample Database Connection Syntax for ASP and SQL Server.
Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server
Dim my_search
' update the db_server with your server and instance
db_server = "mybox\server1"
db_name = "AdventureWorks2008"
db_username = "s1user"
db_password = "s1password"
'setup database handler
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("Driver={SQL Server};Server=" & db_server & ";Database=" & db_name &";UID=" & db_username & ";PWD=" & db_password & ";Trusted_Connection=NO;")
'setup query
qry = "SELECT LoginID,BusinessEntityID FROM HumanResources.Employee WHERE LoginID LIKE '%" & Request("search") & "%'"
'execute query
Set oRS = oConn.Execute(qry)
'output status to user
Response.Write "<strong>Search Results for:</strong> " & Request("search") & "<br>"
'loop through and print results
Do until oRs.EOF
Response.Write "<a href=/employee.asp?id=" & oRs.Fields("BusinessEntityID") & ">" & oRs.Fields("LoginID") & "</a><br>"
oRS.MoveNext
Loop
oRs.Close
Set oRs = nothing
Set oConn = nothing
%>
</body>
</html>