| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 753 人关注过本帖
标题:新手查询问题
只看楼主 加入收藏
冰雪飘飘
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2008-4-3
收藏
 问题点数:0 回复次数:8 
新手查询问题
数据库中有一表user,其中user_name,time等是其中的字段,现在想按user_name或time查询,但是运行不行,请帮忙看看!谢谢!
<!--#include file="conn.asp"-->
<%
If request("action")="查询" Then
    set rs=server.createobject("adodb.recordset")

    If request("st")="客户名称" Then
        sqltext="select * from [user] where  user_name="&request("sc") &" order by user_name asc"
        ElseIf request("st")="加入日期" Then
        sqltext="select * from [user] where time="& request("sc") &" order by user_name asc"
        End If
 rs.open sqltext,conn,1,1
  End If

%>
<HTML>
<HEAD>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<title>查询</title>
</HEAD>
<body>
<FORM name=form1 method="post"  action="User_look.asp" onSubmit="return false;">
<div align="center">请选择查询条件:
<SELECT  size=1 name=st>
<OPTION value=kename selected>客户名称
<OPTION value=khtime>加入日期
</SELECT>
    <INPUT type="text" size=15 name=sc>
    <INPUT type="submit" value="查询" name="action">
</div>
</FORM>
<br>
<br>
 <%
total=0
do while not rs.eof
%>
<table border="1" width="100%" cellspacing="0" cellpadding="0">
     <tr height="35">
      <td width="8%" height="30" align="center" bgcolor= #66CCFF><b>加入日期</b></td>
      <td width="13%" height="30" align="center" bgcolor=#66CCFF><b>客户名称</b></td>
      <td width="7%" height="30" align="center" bgcolor=#66CCFF><b>阶段</b></td>
      <td width="5%" height="30" align="center" bgcolor=#66CCFF><b>类型</b></td>
      <td width="8%" height="30" align="center" bgcolor=#66CCFF><b>客户来源</b></td>
      <td width="8%" height="30" align="center" bgcolor=#66CCFF><b>主联系人</b></td>
      <td width="10%" height="30" align="center" bgcolor=#66CCFF><b>电话</b></td>
      <td width="13%" height="30" align="center" bgcolor=#66CCFF><b>详细地址</b></td>
      <td width="13%" height="30" bgcolor=#66CCFF align="center"><b>电子邮件</b></td>
      <td width="8%" height="30" align="center" bgcolor=#66CCFF><b>主页</b></td>
   </tr>
  

      <tr bordercolor= #FFFFFF>
      <td width="8%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("time")%></td>
      <td width="13%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("user_name")%></td>
      <td width="7%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("stage")%></td>
      <td width="5%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("type")%></td>
      <td width="8%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("source")%></td>
      <td width="8%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("contactor")%></td>
      <td width="10%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("telephone")%></td>
      <td width="13%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("address")%></td>
      <td width="13%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("email")%></td>
      <td width="8%" height="35" align="center" bgcolor="#F5F5F5"><%=rs("network")%></td>
    </tr>
</table>
<%
   rs.movenext()
   total=total+1
   loop
 %>   
  <% if not rs.eof or rs.bof then %>

   <font color="#00CCFF">共<%=(total)%>条客户信息</font>
   <% end if %>
</body>
</html>
搜索更多相关主题的帖子: 查询 
2008-04-17 17:49
tianyu123
Rank: 1
等 级:新手上路
威 望:2
帖 子:576
专家分:0
注 册:2007-8-26
收藏
得分:0 
这样试试
If request("st")="客户名称" Then
        sqltext="select * from [user] where  user_name='"&request("sc") &"' order by user_name asc"
        ElseIf request("st")="加入日期" Then
        sqltext="select * from [user] where time=#"& request("sc") &"# order by user_name asc"
        End If

改变一切,须从改变观念开始!
2008-04-17 17:54
冰雪飘飘
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2008-4-3
收藏
得分:0 
不可以啊!我一运行CPU就达到100%,为什么啊!我也不知道哪里错了,前段时间刚接触ASP的
希望各位老师能帮忙
2008-04-17 19:09
ysm140
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2008-3-27
收藏
得分:0 
[bo]以下是引用 [un]tianyu123[/un] 在 2008-4-17 17:54 的发言:[/bo]

If request("st")="客户名称" Then
        sqltext="select * from  where  user_name='"&request("sc") &"' order by user_name asc"
        ElseIf request("st")="加入日期" Then
        sqltext="select * fr ...



这样应该就正确了,cpu100%可能是你程序其它地方的问题了
2008-04-17 20:01
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
不需要那么复杂,直接
select * from [user] where  user_name='"&request("sc") &"' or time='"&request("sc")&"'  order by user_name asc

注意:时间查询的时间格式一定不能写错,否责出错
2008-04-17 21:26
冰雪飘飘
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2008-4-3
收藏
得分:0 
还是不可以,现在主要是连页面都没法显示,我只要运行这段代码,CPU就达100%,非常的慢。我查过了,只要我取消该进程,CPU又恢复了。真的好奇怪啊
2008-04-18 00:54
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
<FORM name=form1 method="post"  action="User_look.asp" onSubmit="return false;" >
2008-04-18 16:03
子夜老狼
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2008-4-18
收藏
得分:0 
学习一下
2008-04-18 23:51
冰雪飘飘
Rank: 1
等 级:新手上路
帖 子:53
专家分:0
注 册:2008-4-3
收藏
得分:0 
对是<FORM name=form1 method="post"  action="User_look.asp" onSubmit="return false;" >
有问题,上面设置中也有问题,现在已经解决!
谢谢各位!
2008-04-19 00:21
快速回复:新手查询问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015983 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved