这是我刚接触mssql时做的一个搜索,根据楼主的情况做了一下调整。
<%
key =Request("key")
//response.write key
otype =Request("otype")
//response.write otype
set rs =Server.CreateObject("adodb.recordset")
if otype="u_name" then
sql ="select u_name as '操作员',price as '收费金额',date as '收费日期' from tb where u_name like '%" & key & "%'"
elseif otype="price" then
sql ="select u_name as '操作员',price as '收费金额',date as '收费日期' from tb where price like '%" &key & "%'"
elseif otype="date" then
sql ="select u_name as '操作员',price as '收费金额',date as '收费日期' from tb where date like '%" &key & "%'"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('没有找到数据!');"
response.write "history.go(-1);"
response.write "</script>"
response.end
else
i=0
do while not rs.eof
%>
<%=rs.fields(i).name%>
<%=rs("收费金额")%>
<%=rs("收费日期")%><br>
<%
i=i+1
rs.movenext
loop
%>
<%
rs.close
set rs=nothing
end if
%>