| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 705 人关注过本帖
标题:学习中受“挫”
只看楼主 加入收藏
it2008chf
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-5-6
收藏
 问题点数:0 回复次数:4 
学习中受“挫”
今天小有兴趣做了三个页面用来实现记录的修改工作。可是谁知老天如此不配合。测试到第三个页面怎么的也能不过,看也老长时间都看不出什么问题来。请各位仁兄帮帮忙!!

第一个页面代码是一个目录页
<!--#include file="conn.asp"-->
<!--连接表,在目录布面中-->
<% dim exec
exec="select * from jibenxinxi"
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,1 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>记录修改页面</title>
</head>
<body>
<table border="1" bordercolor="#3399CC" class="neirong" >
<% if rs.eof and rs.bof then %>
<tr><td>暂无记录</td>
<tr>
<% else %>
<tr>
<% do while (not rs.eof) %>
<td><a href="xgnr.asp?bh=<% =rs("bh") %>"><% response.write(rs("xm")) %></a></td>
<% rs.movenext
loop %>
</tr>
<% end if %>
</table>
</body>
</html>
第二个页面代码修改做用。
<!--#include file="conn.asp"-->
<% dim xbh
xbh="1"
if(request.querystring("bh")<>" ") then
xbh=request.QueryString("bh")
end if %>
<% dim exec
exec="select * from jibenxinxi where bh=" + xbh
set rs=server.createobject("adodb.recordset")
rs.open exec,conn,1,3 %>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改页面</title>
<style type="text/css">
<!--
.STYLE1 {
    color: #FFFFFF;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: lighter;
    font-variant: normal;
    text-transform: none;
}
-->
</style>
</head>

<body>
<table width="489" height="109" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
  <tr>
    <th colspan="2" bgcolor="#000000" scope="row"><span class="STYLE1">注册表</span></th>
  </tr>
  <tr bgcolor="#666666">
    <th width="148" class="STYLE1" scope="row">姓名</th>
    <td width="468" rowspan="4"><form name="form1" method="post" action="xgcg.asp">
      <table width="436" border="0" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#000000">
        <tr>
          <th scope="row"><label>
            <input name="xm" type="text" size="60" value="<% =rs("xm") %>">
          </label></th>
        </tr>
        <tr>
          <th scope="row"><label>
            <input name="xb" type="text" size="60" value="<% =rs("xb") %>">
          </label></th>
        </tr>
        <tr>
          <th scope="row"><label>
            <input name="nl" type="text" size="60" value="<% =rs("nl") %>">
          </label></th>
        </tr>
        <tr>
          <th scope="row"><label>
            <input name="dh" type="text" size="60" value="<% =rs("dh") %>">
          </label></th>
        </tr>
      </table>
     
  <tr bgcolor="#666666">
    <th class="STYLE1" scope="row">性别</th>
  </tr>
  <tr bgcolor="#666666">
    <th class="STYLE1" scope="row">年龄</th>
  </tr>
  <tr bgcolor="#666666">
    <th height="15" class="STYLE1" scope="row">电话</th>
  </tr>
  <tr bgcolor="#666666">
    <th colspan="2" scope="row">
      <label>
        <input type="submit" name="Submit" value="提交">
        </label>
      <label>
      <input type="reset" name="Submit2" value="重置">
      </label>
    </form>
    <% rs.close
set rs=nothing
conn.close
set conn=nothing %>
    </th>
  </tr>
</table>
</body>
</html>
第三个页面修改成项提示————————问题就出现在这个页面
<!--#include file="conn.asp"-->
<% dim exec,sql,xm,xb,nl,dh
sql="select * from jibenxinxi where bh=" & request.Form("bh")
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,3 这就 是第5行
xm=request.form("xm")
xb=request.form("xb")
nl=request.form("nl")
dh=request.form("dh")
exec=" insert into jibenxinxi (xm,xb,nl,dh) values ('"+ xm +"','"+ xb +"','"+ nl +"','"+ dh +"')"
conn.execute exec %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改成功</title>
</head>

<body>
恭喜你修改第<% =rs("bh") %>记录已成功!
<% rs.close
set rs=nothing
conn.close
set conn=nothing %>
</body>
</html>

提示信息如下:

错误类型:
Microsoft JET Database Engine (0x80040E14)
语法错误 (操作符丢失) 在查询表达式 'bh=' 中。
/xgcg.asp, 第 5 行

[[it] 本帖最后由 it2008chf 于 2008-6-30 17:36 编辑 [/it]]
搜索更多相关主题的帖子: 兴趣 学习 页面 仁兄 老天 
2008-06-30 17:33
tianyu123
Rank: 1
等 级:新手上路
威 望:2
帖 子:576
专家分:0
注 册:2007-8-26
收藏
得分:0 
在第三页面中

sql="select * from jibenxinxi where bh=" & request.Form("bh")
response.write sql '输出一下sql语句 看看bh是否获取到了值
response.end

改变一切,须从改变观念开始!
2008-06-30 17:36
dhdhzzw
Rank: 1
等 级:新手上路
帖 子:949
专家分:0
注 册:2007-8-13
收藏
得分:0 
sql="select * from jibenxinxi where bh=" & request.Form("bh")
书写方法出错。
2008-06-30 17:41
fuhuijun
Rank: 1
等 级:新手上路
帖 子:407
专家分:0
注 册:2007-10-30
收藏
得分:0 
response.write (bh)输出一下,看是不是空的
2008-06-30 17:54
it2008chf
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2008-5-6
收藏
得分:0 
自问自答
谢了,知道问题出在那里了/
在第二个页面里面少了个<input type="hidden" name="bh" value="<%=rs("bh")%>">隐藏域。

也就是说在第二页向第三页传数据 的时间,bh没有数据 。里面是空的。
2008-06-30 17:54
快速回复:学习中受“挫”
数据加载中...
 
   



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

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