?? person_result_query.asp
字號:
<!--#include file="../../Include/TimeOut.asp"-->
<!--#include file="../../include/AdoConn.asp"-->
<%
table_name=Request.QueryString("tablename")'表名
' dim strconn '連接串
' dim objconn 'connection對象
' dim objrec 'recordset對象
' dim strsql 'sql語句
' dim table_name '數據表名
set objres=server.CreateObject ("adodb.recordset")
objres.CursorType =3
objres.CursorLocation =3
objres.LockType =2
strsql="select * from "+table_name
if Request.QueryString("submit")="submit" then '提交而來
strsql=strsql+" where "+ Request.Form("radio1")
objres.Open strsql,strconn
actionstr=Request.QueryString("aspname")+"?"+objres.Fields(0).Name +"="+objres.Fields(0).Value
if objres.Fields.Count >1 then
for i=1 to objres.Fields.Count -1
actionstr=actionstr+"&"+objres.Fields(i).Name +"="+objres.Fields(i).Value
next
end if
' Response.Redirect actionstr
session("objres.fields(0).name")=objres.Fields(0).Value
end if
objres.Open strsql,strconn
'接收數據
selectname1=Request.Form("selectname1") '列名1
selectname2=Request.Form("selectname2") '列名2
selectrel1=Request.Form("selectrel1") '關系1
selectrel2=Request.Form("selectrel2") '關系2
textfield1=Request.Form("textfield1") '輸入1
textfield2=Request.Form("textfield2") '輸入2
radio=Request.Form("radiobutton") '兩個條件之間的關系
function selrel(intrel) '將索引值轉化為對應運算符
select case intrel
case "0"
selrel=" = "
case "1"
selrel=" <> "
case "2"
selrel=" > "
case "3"
selrel=" < "
case "4"
selrel=" <= "
case "5"
selrel=" >= "
case else
selrel=" like "
end select
end function
item0type=cint(objres.Fields.Item(cint(selectname1)).Type )'處理主鍵的不同數據類型
function type0()
select case item0type
case 3
type0=""
case 135
type0="#"
case 200
type0="'"
case else
end select
end function
dim where1 'where語句第一部分
dim where2 'where語句第二部分
if not textfield1=""then '處理第一個查詢條件
select case cint(objres.Fields.Item(cint(selectname1)).Type )
case 3 'int類型
where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+textfield1
case 135 'datetime類型
where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"#"+textfield1+"#"
case 200 'VC類型
select case selectrel1
case "6" '包含
where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"'%"+textfield1+"%'"
case "7" '類似
where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"'"+textfield1+"%'"
case else '其它
where1=objres.Fields.Item(cint(selectname1)).Name +selrel(selectrel1)+"'"+textfield1+"'"
end select
case else '其他類型,不作處理
end select
end if
if not textfield2=""then '處理第二個查詢條件
select case cint(objres.Fields.Item(cint(selectname2)).Type )
case 3 'int類型
where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+textfield2
case 135 'datetime類型
where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"#"+textfield2+"#"
case 200 'VC類型
select case selectrel2
case "6" '包含
where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"'%"+textfield2+"%'"
case "7" '類似
where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"'"+textfield2+"%'"
case else '其它
where2=objres.Fields.Item(cint(selectname2)).Name +selrel(selectrel2)+"'"+textfield2+"'"
end select
case else '其他類型,不作處理
end select
end if
'處理sql語句
if not where1="" then
if not where2="" then '兩個條件都填寫了,考慮兩個條件之間的邏輯關系
if radio="andrel" then strsql="select * from "+table_name+" where "+where1 +" and "+where2 else strsql="select * from "+table_name+" where "+where1 +" or "+where2
else
strsql="select * from "+table_name+" where "+where1
end if
else
if not where2="" then
strsql="select * from "+table_name+" where "+where2
else
strsql="select * from "+table_name
end if
end if
objres.Close
objres.Open strsql,strconn
reccount=objres.RecordCount '記錄條數
itemcount=2 '烈數
redim arrayitemname(itemcount-1)'以數組形式記錄列名
arrayitemname(0)="用戶編碼"
arrayitemname(1)="用戶姓名"
' itemcount=objres.Fields.Count '烈數
if reccount>0 then '以數組形式處理記錄
redim arrayrecord (reccount-1,itemcount-1)
for i=0 to reccount-1
for j=0 to itemcount-1
arrayrecord(i,j)=objres(arrayitemname(j)).Value
next
objres.MoveNext
next
' redim arrayitemname(itemcount-1)'以數組形式記錄列名
' for j=0 to itemcount-1
' arrayitemname(j)=objres.Fields(j).name
' next
end if
%>
<%
dim Pname
Pname=Request.QueryString("Pname")
%>
<script language="vbscript">
function back()
history.back
end function
</script>
<script language=javascript>
function updateparent(textfield,objLength){
if (objLength==1)//只有一項
{opener.document.forms(0).<%=Pname%>.value=textfield.value }
if (objLength==0)//有多項
{
for(i=0;i<textfield.length;i++)
{
if (textfield(i).checked) opener.document.forms(0).<%=Pname%>.value=textfield(i).value
}
}
window.close()
}
//end hiding
</script>
<html>
<head>
<title>查詢結果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/CssLib/Cssbutton.css">
<STYLE type=text/css>A {
TEXT-DECORATION: none
}
TD {FONT-SIZE: 9pt}
</STYLE>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action="_result_Query.asp?submit=submit&tablename=<%=table_name%>&aspname=<%=Request.QueryString("aspname")%>">
<div align="center">
<table style="font-size:9pt" width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="75" height="20" valign="bottom">
<div align="center"><img src="../../public/images/find_2.gif" width="75" height="25" border="0"onclick="back()"></div>
</td>
<td width="75" height="20" valign="bottom"><img src="../../public/images/find_3.gif" width="75" height="25"></td>
<td width="150" height="20"> </td>
</tr>
<tr>
<td colspan="3" bgcolor="#6699FF"></td>
</tr>
</table>
<table width="300" border="1" cellspacing="0" cellpadding="0" bordercolor="#6699FF">
<tr>
<td height="130">
<%if reccount >0 then '查到了符合要求的記錄%>
<font color="#0066CC"><br>
您的查詢結果如下:</font>
<input type="button" value="確定" id=button1 name=button1 onClick="javascript:<%if reccount=1 then %>updateparent(code,1) <%else%> updateparent(code,0)<%end if%>" class="button">
<table width="250" border="0" cellspacing="0" cellpadding="0" align="center" height="30">
<tr>
<td> </td>
<td> </td>
<%for i=0 to itemcount-1 %>
<td><%=arrayitemname(i)%></td>
<%next%>
</tr>
</table>
<table width="250" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="151" valign="top">
<% if reccount>5 then '超過5條記錄時滾動顯示%>
<MARQUEE direction=down height=150 width=200 scrollAmount=1 scrollDelay=100 align="center">
<% end if%>
<table width="250" border="0" cellspacing="0" cellpadding="0" align="center" >
<% i=0' 第一行%>
<tr>
<td> </td>
<td>
<input type="radio" id="radio1" name="code" checked value="<% Response.write arrayrecord(i,0)%>">
</td>
<%for j=0 to itemcount-1 %>
<td><%=arrayrecord(i,j)%></td>
<%next%>
</tr>
<% if reccount>1 then '第二行以后
for i=1 to reccount -1%>
<tr>
<td> </td>
<td>
<input type="radio" id="radio1" name="code" value="<% Response.write arrayrecord(i,0)%>">
</td>
<%for j=0 to itemcount-1 '顯示一行%>
<td><%=arrayrecord(i,j)%></td>
<%next%>
</tr>
<% next
end if%>
</table>
</MARQUEE>
</td>
</tr>
</table>
<br>
<%else '無符合要求的記錄%>
<p><font color="#0066CC"> <br>
對不起,沒有符合您的查詢要求的記錄</font> </p>
<table width="250" border="0" cellspacing="0" cellpadding="0" align="center" height="70" bgcolor="#FFF8F4">
<tr>
<td> </td>
</tr>
</table>
<% end if%>
</td>
</tr>
</table>
</div>
</form>
<div align="center"><br>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -