CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

asp问题求救!(附代码)

楼主wangxiaolei456(asp&&java)2003-11-01 10:58:38 在 Web 开发 / ASP 提问

<!--#   include   file="conn.inc"-->  
  <%   @   language=vbs   %>  
  <%  
  const   Head="学生信息查询"  
  dim   conn,strconn  
  set   conn=server.CreateObject("adodb.connection")  
  strconn="provider=sqloledb;user   id=sa;password=;initial   catalog=wang;data   source=wangxiaolei"  
  conn.Open   strconn  
  sno=trim(Request.Form("sno"))  
  sname=trim(Request.Form("sname"))  
  ssex=trim(Request.Form("ssex"))  
  sclass=trim(Request.Form("sclass"))  
  sdept=trim(Request.Form("sdept"))  
  if   sno<>""   and   sname<>""     then  
            condition="学号="&sno&"   and   姓名   like   '%"&sname&"%'"  
   
  end   if  
  dim   strsql  
  strsql="select   *   from   student   where   "&condition  
  set   string1=conn.Execute(strsql)  
  set   conn=nothing  
  %>  
  <html>  
  <head>  
  <meta   http-equiv="content-type"   content="text/html;charset=gb_2312-80">  
  <title>学生信息查询</title>  
  </head>  
  <body   bgcolor="#ffffff">  
  <h2>  
  <center>  
  学生信息查询&nbsp&nbsp<a   href="xsxx.html">返回</a>  
  </center>  
  </h2>  
  <table   align=left   width=800   cellspacing="1"   cellspacing="1"   border="1"   bordercolor="#ffffff"   bordercolordark="#b0e0e6"   bordercolorlight="#000066"   height="44">  
    <tr   bgcolor="#b0e0e6"   bordercolor="#000066">  
    <td   align="center"   width="160"   height="13">    
    <font   style="font-size:14px"><b>学号</b></font></td>  
    <td   align="center"   width="160"   height="13">  
    <font   style="font-size:14px"><b>姓名</b></font></td>  
    <td   align="center"   width="160"   height="13">  
    <font   style="font-size:14px"><b>性别</b></font></td>  
    <td   align="center"   width="160"   height="13">  
    <font   style="font-size:14px"><b>类别</b></font></td>  
    <td   align="center"   width="160"   height="13">  
    <font   style="font-size:14px"><b>系别</b></font></td>  
    <%   do   while   not   string1.eof%>  
    <tr>  
    <td   align=center   bgcolor="#ffffff"   bordercolor="#eeeeff"   width="160"  
    nowrap   height="19"><font   style="font-size:14px">  
    <%     Response.Write(string1("sno"))%></font></td>  
    <td   align=center   bgcolor="#eeeeff"   bordercolor="#ffffff"   width="160"  
    nowrap   height="19"><font   style="font-size:14px">  
    <%     Response.Write(string1("sname"))%></font></td>  
    <td   align=center   bgcolor="#ffffff"   bordercolor="#eeeeff"   width="160"  
    nowrap   height="19"><font   style="font-size:14px">  
    <%     Response.Write(string1("ssex"))%></font></td>  
    <td   align=center   bgcolor="#eeeeff"   bordercolor="#ffffff"   width="160"  
    nowrap   height="19"><font   style="font-size:14px">  
    <%     Response.Write(string1("sclass"))%></font></td>  
    <td   align=center   bgcolor="#ffffff"   bordercolor="#eeeeff"   width="160"  
    nowrap   height="19"><font   style="font-size:14px">  
    <%     Response.Write(string1("sdept"))%></font></td>  
    </tr>  
    <%  
    string1.movenext  
    loop  
    %>  
    </table>  
    </body>  
    </html>  
  大家帮我看看哪里有问题啊?  
  编译总是出错  
  去掉condition条件后又可以了 问题点数:0、回复次数:8Top

1 楼fastson()回复于 2003-11-01 11:07:21 得分 0

在  
  strsql="select   *   from   student   where   "&condition  
  后面加上  
  response.write   strsql  
  response.end  
  运行一遍,然后把生成的sql语句发上来Top

2 楼chinann(臣煌)回复于 2003-11-01 14:15:52 得分 0

请问楼上,你为什么要加上你写的那个代码呢??  
   
  能说明理由吗?谢谢!!Top

3 楼avonqin(不再看连续剧)回复于 2003-11-01 14:28:30 得分 0

仅仅测试Top

4 楼avonqin(不再看连续剧)回复于 2003-11-01 14:31:12 得分 0

condition="学号='"&sno&"'   and   姓名   like   '%"&sname&"%'"Top

5 楼Tal(Tal)回复于 2003-11-01 14:38:31 得分 0

sno=trim(Request.Form("sno")   &   "")  
  sname=trim(Request.Form("sname")   &   "")  
  ssex=trim(Request.Form("ssex")   &   "")  
  sclass=trim(Request.Form("sclass")   &   "")  
  sdept=trim(Request.Form("sdept")   &   "")  
  if   sno   &   ""   <>   ""   and   sname   &   ""   <>   ""     then  
            condition="   and   学号="   &   sno   &   "   and   姓名   like   '%"   &   sname   &   "%'"  
   
  end   if  
  dim   strsql  
  strsql="select   *   from   student   where   1=1   "   &   conditionTop

6 楼wangxiaolei456(asp&&java)回复于 2003-11-01 23:44:08 得分 0

学生信息查询     返回    
  学号   姓名   性别   类别   系别    
  sno   sname   ssex   sclass   sdept    
  sno   sname   ssex   sclass   sdept    
  sno   sname   ssex   sclass   sdept    
  sno   sname   ssex   sclass   sdept    
  sno   sname   ssex   sclass   sdept    
  上层的楼主,这是按你的改后的结果啊  
  还是不对啊Top

7 楼wangxiaolei456(asp&&java)回复于 2003-11-02 12:30:20 得分 0

怎么没人回答了?  
  Top

8 楼Tal(Tal)回复于 2003-11-03 11:33:58 得分 0

<%  
  sno   =   trim(Request.Form("sno")   &   "")  
  sname   =   trim(Request.Form("sname")   &   "")  
  ssex   =   trim(Request.Form("ssex")   &   "")  
  sclass   =   trim(Request.Form("sclass")   &   "")  
  sdept   =   trim(Request.Form("sdept")   &   "")  
  condition   =   ""  
  if   sno   &   ""   <>   ""   then  
            condition   =   "   and   学号='"   &   sno   &   "'   "  
  end   if  
  if   sname   &   ""   <>   ""   then  
  "   and   姓名   like   '%"   &   sname   &   "%'"  
  if   ssex&   ""   <>   ""   then  
            condition   =   condition   &   "   and   性别='"   &   ssex   &   "'   "  
  end   if  
  if   sclass   &   ""   <>   ""   then  
            condition   =   condition   &   "   and   类别='"   &   sclass   &   "'   "  
  end   if  
  if   sdept   &   ""   <>   ""   then  
            condition   =   condition   &   "   and   系别='"   &   sdept   &   "'   "  
  end   if  
  dim   strsql  
  strsql="select   *   from   student   where   1=1   "   &   condition  
  '你再试试  
  %>Top

相关问题

  • asp源代码!
  • 急需asp代码!!
  • asp代码问题
  • ASP代码问题?
  • 查看asp源代码
  • 寻觅asp源代码
  • ASP代码(急),谢谢
  • ASP NET的代码分离??
  • asp调用代码问题
  • 求ASP一简单代码!

关键词

得分解答快速导航

  • 帖主:wangxiaolei456

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo