| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 433 人关注过本帖
标题:根据FIF的教程制作的数据库修改资料 总失败 求高手帮助
只看楼主 加入收藏
aspwyf
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2012-6-26
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:1 
根据FIF的教程制作的数据库修改资料 总失败 求高手帮助
如下代码:

管理会员页代码:
<!-- #include file="db.inc.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员管理</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
margin-bottom: 0px;
background-image: url();
background-repeat: no-repeat;
}
-->
</style></head>
<body>
<%
set rst=server.createobject("adodb.recordset")
on error resume next
if request.Querystring("act")="del"then'如果是删除记录
id=request.Querystring("id")
conn.begintrans
'conn.execute"delete from user where u_id="& id
'conn.execute"delete from info where i_uid="& id
rst.open"select * from user where u_id=" & id,conn,1,3
rst.delete
rst.close
rst.open"select * from info where i_uid=" & id,conn,1,3
rst.delete
rst.close
if err.number<>0 then
conn.rollbacktrans
response.Write"删除会员失败!"
else

response.Write"删除会员成功!"
end if
end if
%>
<table width="800" height="747" border="0" align="center" cellspacing="0">
<tr>
<td height="222" align="center" valign="top" background="img/hygl.jpg"><table width="800" border="0" cellspacing="0">
<tr>
<td width="84" height="164">&nbsp;</td>
<td width="625">&nbsp;</td>
<td width="85">&nbsp;</td>
</tr>
<tr>
<td height="472">&nbsp;</td>
<td align="center" valign="middle" bgcolor="#F9F9F9"><table width="95%" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="8%" align="center">ID</td>
<td width="18%" align="center">用户名</td>
<td width="16%" align="center">姓名</td>
<td width="7%" align="center">性别</td>
<td width="8%" align="center">年龄</td>
<td width="8%" align="center">会员</td>
<td width="35%" align="center">操作</td>
</tr>
<%
set rst=server.createobject("adodb.recordset")
sql="select * from user,info where u_id=i_uid"
rst.open sql,conn,1,1
while not rst.eof
%>
<tr>
<td align="center"><%=rst("u_id")%></td>
<td align="center"><%=rst("u_user")%></td>
<td align="center"><%=rst("i_name")%></td>
<td align="center"><%=rst("i_sex")%></td>
<td align="center"><%=rst("i_age")%></td>
<td align="center"><%
                    if rst("i_vip")then
                    response.Write("是")
                    else
                    response.Write("否")
                    end if
                    %></td>
             <td align="center"><a href="modify.asp?id=<%=rst("u_id")%>">修改资料 </a>
<a href="admin.asp?act=del&id=<%=rst("u_id")%>">删除会员</a></td>
</tr>
<%
rst.movenext
wend
rst.close
%>
</table></td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="66">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>



修改页面代码:
<!-- #include file="db.inc.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>会员资料修改</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
margin-bottom: 0px;
background-image: url();
background-repeat: no-repeat;
}
.STYLE1 {color: #FF0000}
-->
</style></head>
<body>
<%
set rst=server.createobject("adodb.recordset")
on error resume next
id=request.Querystring("id")
if request.Querystring("act")="modify"then'如果是修改记录
conn.begintrans
rst.open"select * from user where u_id=" & id,conn,1,3
rst("u_user")=request.Form("f_user")
rst("u_code")=request.Form("f_code")
rst.update
rst.close
rst.open"select * from info where i_uid=" & id,conn,1,3
rst("i_name")=request.Form("f_name")
rst("i_sex")=request.Form("f_sex")
rst("i_age")=request.Form("f_age")
if request.Form("f_vip")=1 then
rst("i_vip")=true
else
rst("i_vip")=false
end if
rst.update
rst.close
if err.number<>0 then
conn.rollbacktrans
response.Write"修改会员失败!"
else

response.Write"修改会员成功!"
end if
end if
%>
<table width="800" height="573" border="0" align="center" cellspacing="0">
<tr>
<td height="573" align="center" valign="top" background="img/hyzlxg.jpg"><table width="800" border="0" cellspacing="0">
<tr>
<td width="73" height="164">&nbsp;</td>
<td width="646">&nbsp;</td>
<td width="75">&nbsp;</td>
</tr>
<tr>
<td height="337">&nbsp;</td>
<td align="center" valign="middle" bgcolor="#F9F9F9"><a href="admin.asp">返回会员列表</a>
<%
rst.open"select * from user where u_id=" & request.QueryString("id"),conn,1,1
%>
<form id="form1" name="form1" method="post"action="modify.asp?act=modify&id=<%=request.Querystring("id")%>">
<table width="90%" border="1" align="center" cellpadding="5" cellspacing="0">
<tr>
<td colspan="3">请在下面修改会员资料,红色<span class="STYLE1">*</span>号所标示的选项为必填项</td>
</tr>
<tr>
<td width="24%" align="right">用户名:</td>
<td width="37%" align="left"><input name="f_user" type="text" id="f_user" value="<%=rst("u_user")%> "/></td>
<td width="39%" align="left"><span class="STYLE1">*
</span></td>
</tr>
<tr>
<td align="right">密码:</td>
<td align="left"><input name="f_code" type="text" id="f_code"value="<%=rst("u_code")%> "/></td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<%
rst.close
rst.open"select * from info where i_uid=" & request.QueryString("id"),conn,1,1
%>
<tr>
<td align="right">姓名:</td>
<td align="left"><input name="f_name" type="text" id="f_name"value="<%=rst("i_name")%> "/></td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">性别:</td>
<td align="left"><select name="f_sex" id="f_sex">
<option value="男" selected="selected">男</option>
<option value="女"<%=if rst("i_sex")="女"then response.Write"selected"%> >女</option>
</select>              </td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">年龄:</td>
<td align="left"><input name="f_age" type="text" id="f_age" size="8" value="<%=rst("i_age")%> "/></td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<tr>
<td align="right">是否会员:</td>
<td align="left"><input name="f_vip" type="radio" value="1" <%=if rst("i_vip")then response.Write"checked"%>/>

<input type="radio" name="f_vip" value="0"<%=if not rst("i_vip")then response.Write"checked"%> />
否</td>
<td align="left"><span class="STYLE1">*</span></td>
</tr>
<%
rst.close
%>
<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="修改会员资料" />
&nbsp;&nbsp;&nbsp;
<input type="reset" name="Submit2" value="重置表单" /></td>
</tr>
</table>
</form>
</td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>

管理页能删除  修改页不能修改 可代码按教程的  求解
搜索更多相关主题的帖子: 修改资料 content include 数据库 
2012-06-26 14:36
kangli_kl
Rank: 6Rank: 6
等 级:侠之大者
威 望:2
帖 子:134
专家分:489
注 册:2008-4-5
收藏
得分:14 
代码太长。。。。

求上而得中,求中而得下。
2012-06-27 14:41
快速回复:根据FIF的教程制作的数据库修改资料 总失败 求高手帮助
数据加载中...
 
   



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

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