⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchdb.asp

📁 JavaScript_VBScript网页编程实例
💻 ASP
字号:
<%@ LANGUAGE=VBScript %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>查询结果</title>
</head>
<body>
<h1 align=center>查询结果为:</h1>
<div style="text-align:center">
<%
Set Con = Server.CreateObject( "ADODB.Connection" )     
Con.Provider = "Microsoft.Jet.OLEDB.4.0"                                      
Con.Open "d:\tushu.mdb"                                        
Set RS = Server.CreateObject( "ADODB.Recordset" )                                           
RS.ActiveConnection = Con
select case Request.Form("selectdb")
case "计算机类"
dbname="computer"
case "数学类"
dbname="math"
case "所有数据库"
dbname="all"
end select

whstr=""
if Request.Form("YGT")<>"" then
whstr=whstr&"出版时间>"&Request.Form("YGT")
end if
if Request.Form("YLT")<>"" then
if whstr="" then
whstr=whstr&"出版时间<"&Request.Form("YLT")
else
whstr=whstr&" AND 出版时间<"&Request.Form("YLT")
end if
end if
if Request.Form("PRESS")<>"" then 
if whstr="" then 
whstr=whstr&"出版社='"&Request.form("PRESS")&"'"
else
whstr=whstr&" AND 出版时间<"&Request.Form("YLT")
end if
end if

t=1
if dbname="all" then 
t=0
end if
if t=0 then
dbname="computer"
end if

while t<2
response.write "<P>"
response.write "在数据库"&dbname&"中:"

select case Request.Form("R1")
case "V1"
SQL="SELECT * FROM "&dbname&" WHERE 书名='"&Request.Form("T1")&"'"
if whstr<>"" then SQL=SQL&" AND "&whstr
Set RS=con.Execute(SQL)
if RS.EOF then
Response.Write"没有找到记录"
else
Response.Write "<TABLE BORDER=2>"
Response.write "<TR>"
for i=0 to RS.fields.count-2
Response.Write "<TH>"&RS(i).name&"</TH>"
next
Response.Write "</TR>"
have=0
do while Not RS.EOF
have=have+1
Response.write "<TR>"
for i=0 to RS.Fields.Count-2
Response.Write "<TD>"&RS(i)&"</TD>"
next
Response.write "</TR>"
RS.MoveNext
loop
Response.Write "</table>"
Response.Write "<HR>"
Response.Write "共找到"&cstr(have)&"条记录"
end if 

case "V2"
SQL="SELECT * FROM "&dbname&" WHERE 书号='"&Request.Form("T1")&"'"
if whstr<>"" then SQL=SQL&" AND "&whstr

Set RS=con.Execute(SQL)
if RS.EOF then
Response.Write"没有找到记录"
else
Response.Write "<TABLE BORDER=2>"
Response.write "<TR>"
for i=0 to RS.fields.count-2
Response.Write "<TH>"&RS(i).name&"</TH>"
next
Response.Write "</TR>"
have=0
do while Not RS.EOF
have=have+1
Response.write "<TR>"
for i=0 to RS.Fields.Count-2
Response.Write "<TD>"&RS(i)&"</TD>"
next
Response.write "</TR>"
RS.MoveNext
loop
Response.Write "</table>"
Response.Write "<HR>"
Response.Write "共找到"&cstr(have)&"条记录"
end if 

case "V3"
SQL="SELECT * FROM "&dbname&" WHERE 作者='"&Request.Form("T1")&"'"
if whstr<>"" then SQL=SQL&" AND "&whstr

Set RS=con.Execute(SQL)
if RS.EOF then
Response.Write"没有找到记录"
else
Response.Write "<TABLE BORDER=2>"
Response.write "<TR>"
for i=0 to RS.fields.count-2
Response.Write "<TH>"&RS(i).name&"</TH>"
next
Response.Write "</TR>"
have=0
do while Not RS.EOF
have=have+1
Response.write "<TR>"
for i=0 to RS.Fields.Count-2
Response.Write "<TD>"&RS(i)&"</TD>"
next
Response.write "</TR>"
RS.MoveNext
loop
Response.Write "</table>"
Response.Write "<HR>"
Response.Write "共找到"&cstr(have)&"条记录"
end if 
end select
t=t+1
dbname="math"
wend
con.close
%>
</div>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -