请帮助查验数据更新脚本 高分回报

lq7667 lq7667 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
无论怎么试,都无法给数据表加新记录,烦请查看我的代码.

<!--#include file="conn.asp"-->
<%
dim Action
dim rs,sql,rsClass,sqlClass
dim ID,BigClassName,SmallClassName,Title,Product_Id,SpecialName,Spec,Newproduct,Price,Unit,Memo,Key,Elite,Passed,Content,IncludePic,massage

Action=trim(request("Action"))
ID=trim(request("ID"))


if Action="Save" then
set rs=server.createobject("adodb.recordset")
sql="select * from product where ID="&ID
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.cloase
set rs=nothing
call CloseConn()
response.redirect "ProductManage.asp"
end if
rs("BigClassName")=BigClassName
rs("SmallClassName")=SmallClassName
rs("Product_Id")=Product_Id
rs("SpecialName")=SpecialName
rs("Spec")=Spec
rs("Unit")=Unit
rs("Memo")=Memo
rs("Passed")=Passed
rs("Content")=Content
rs.update
else
if Action="Add" then
BigClassName=trim(request("BigClassName"))
SmallClassName=trim(request("SmallClassName"))
Product_Id=trim(request("Product_Id"))
SpecialName=trim(request("SpecialName"))
Spec=trim(request("Spec"))
Newproduct=trim(request("Newproduct"))
Price=trim(request("Price"))
Unit=trim(request("Unit"))
Memo=trim(request("Memo"))
Key=trim(request("Key"))
Elite=trim(request("Elite"))
Passed=trim(request("Passed"))
Content=trim(request("Content"))
IncludePic=trim(request("IncludePic"))
Title=trim(request("Title"))
BigClassName=trim(request("Title"))

If Title="" Then
response.write "SORRY <br>"
response.write "请输入产品名称!!<a href=""javascript:history.go(-1)"">返回重输</a>"
response.end
end if
If BigClassName="" Then
response.write "SORRY <br>"
response.write "产品大类不能为空!!<a href=""javascript:history.go(-1)"">返回重输</a>"
response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from product"
rs.open sql,conn,1,3
massage="添加产品"
rs.addnew
rs("BigClassName")=BigClassName
rs("SmallClassName")=SmallClassName
rs("Product_Id")=Product_Id
rs("SpecialName")=SpecialName
rs("Spec")=Spec
rs("Unit")=Unit
rs("Memo")=Memo
rs("Passed")=Passed
rs("Content")=Content
rs.update
rs.cloase
set rs=nothing
call CloseConn()
response.redirect "ProductManage.asp"
else
if Action="Edit" then
set rs=server.createobject("adodb.recordset")
sql="select * from product where ID="&ID
rs.open sql,conn,1,1
if rs.eof and rs.bof then
rs.cloase
set rs=nothing
call CloseConn()
response.redirect "ProductManage.asp"
end if
massage="修改产品"
Action="Save"
else
massage="添加产品"
Action="Add"
end if
end if
end if
%>
<html>
<head>
<title>企业网站管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE type=text/css>
.tes { border:solid; border-width: 0象素 0象素 1象素; border-color: #FFFFFF #FFFFFF #000000}
body,td,th {
font-size: 12px;
color: #666666;
}
</STYLE>
</head>
<body>

<div align="center">
<p><b><font size="5"><%=massage%></font></b></p>
<form method="POST" action="ProductEdit.asp">
<table border="0" id="table1" cellspacing="0" cellpadding="0">



<tr>
<td align="right" style="line-height:20pt">所属大类:</td>
<td>
<%
sqlClass="select * from BigClass"
Set rsClass= Server.CreateObject("ADODB.Recordset")
rsClass.open sqlClass,conn,1,1
if rsClass.eof then
response.Write("还未建立大类")
else
%>
<select size="1" name="BigClassName">
<%
do while not rsClass.eof
%>
<option value="<%=rsClass("BigClassName")%>"><%=rsClass("BigClassName")%></option>
<%
rsClass.movenext
loop
%>
</select>
<%
end if
rsClass.close
set rsClass=nothing
%></td></tr>



<tr>
<td align="right" style="line-height:20pt">所属小类:</td>
<td>
<%
sqlClass="select * from SmallClass"
Set rsClass= Server.CreateObject("ADODB.Recordset")
rsClass.open sqlClass,conn,1,1
if rsClass.eof then
response.Write("还未建立小类")
else
%>
<select size="1" name="SmallClassName">
<%
do while not rsClass.eof
%>
<option value="<%=rsClass("SmallClassName")%>"><%=rsClass("SmallClassName")%></option>
<%
rsClass.movenext
loop
%>
<option value="">不属于任何小类</option>
</select>
<%
end if
rsClass.close
set rsClass=nothing
%></td></tr>

<tr>
<td align="right" style="line-height:20pt">所属专题:</td>
<td>
<%
sqlClass="select * from product where SpeicalName<>''"
Set rsClass= Server.CreateObject("ADODB.Recordset")
rsClass.open sqlClass,conn,1,1
if rsClass.eof then
response.Write("<input type='text' name='SpecialName' size='40' class=tes>")
else
%>
<select size="1" name="SpecialName">
<%
do while not rsClass.eof
%>
<option><%=rsClass("SpecialName")%></option>
<%
rsClass.movenext
loop
%>
</select>
<%
end if
rsClass.close
set rsClass=nothing
%></td></tr>
<tr>
<td align="right" style="line-height:20pt">作为新产品显示:</td>
<td>是<input type="radio" value="y" name="Newproduct">否<input type="radio" value="n" name="Newproduct"></td></tr>
<tr>
<td align="right" style="line-height:20pt">为推荐产品:</td>
<td>是<input type="radio" value="y" name="Elite">否<input type="radio" value="n" name="Elite"></td></tr>
<tr>
<td align="right" style="line-height:20pt">通过审核:</td>
<td>是<input type="radio" value="y" name="Passed">否<input type="radio" value="n" name="Passed"></td></tr>
<tr>
<td align="right" style="line-height:20pt">包含图片:</td>
<td>是<input type="radio" value="y" name="IncludePic">否<input type="radio" value="n" name="IncludePic"></td></tr>
<tr>
<td align="right" style="line-height:20pt">产品售价:</td>
<td><input type="text" name="Price" size="40" class=tes value="<%=rs("Price")%>"></td></tr>
<tr>
<td align="right" style="line-height:20pt">单位:</td>
<td><input type="text" name="Unit" size="40" class=tes value="<%=rs("Unit")%>"></td></tr>
<tr>
<td align="right" style="line-height:20pt">备注:</td>
<td><input type="text" name="Memo" size="40" class=tes value="<%=rs("Memo")%>"></td></tr>
<tr>
<td align="right" style="line-height:20pt">产品内容:</td>
<td><input type="text" name="Content" size="40" class=tes value="<%=rs("Content")%>"></td></tr>
<tr>
<td align="right" style="line-height:20pt">产品名称:</td>
<td><input type="text" name="Title" size="40" class=tes value="<%=rs("Title")%>"></td></tr>
<tr>
<td align="right" style="line-height:20pt">规格:</td>
<td><input type="text" name="Spec" size="40" class=tes value="<%=rs("Spec")%>"></td></tr>
<tr>
<td align="right" style="line-height:20pt">产品编号:</td>
<td><input type="text" name="Product_Id" size="40" class=tes value="<%=rs("Product_Id")%>"></td></tr>
<tr>
<td align="right" style="line-height:40pt">产品图片:</td>
<td><iframe style="top:2px" ID="UploadFiles" src="../upload_Photo.asp?PhotoUrlID=3" frameborder=0 scrolling=no width="300" height="25"></iframe></td></tr>
</table>
<p></p>
<input type="submit" value="提交" name="B1">    <input type="reset" value="重置" name="B2"><input type=hidden value="<%=Action%>" name="Action">




</form>
</div>
<%
rs.close
set rs=nothing
call CloseConn()
%>
</body>
</html>
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
lq7667
ASP 28,401 成员 356,940 内容