难忘的一天周记290字:修改asp网站源码遇到两个问题,产品删除和Product_Id的函数修改

来源:百度文库 编辑:高校问答 时间:2024/05/04 19:45:08
在修改产品系统时,添加产品修改成功了,但是无法删除,请高手帮忙解决,下面是ProductManage.asp
<%@language=vbscript codepage=936 %>
<!--#include file="conn.asp"-->
<!--#include file="admin.asp"-->
<!--#include file="../Inc/Ubbcode.asp"-->
<!--#include file="Inc/Function.asp"-->
<%
dim strFileName
const MaxPerPage=20
dim totalPut,CurrentPage,TotalPages
dim i,j
dim ArticleID
dim Title
dim sql,rs
dim BigClassName,SmallClassName,SpecialName
dim PurviewChecked
dim strAdmin,arrAdmin
PurviewChecked=false
strFileName="ProductManage.asp?BigClassName=" & BigClassName & "&SmallClassName=" & SmallClassName & "&SpecialName=" & SpecialName

Title=Trim(request("Title"))
ArticleID=Request("ArticleID")
BigClassName=Trim(request("BigClassName"))
SmallClassName=Trim(request("SmallClassName"))
SpecialName=trim(request("SpecialName"))

if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if

sql="select * from Products where ArticleID>0"
if session("purview")>4 then
sql=sql & " and Editor='" & Session("admin") & "' and Passed=false"
end if
if Title<>"" then
sql=sql & " and title like '%" & Title & "%' "
end if
if BigClassName<>"" then
sql=sql & " and BigClassName='" & BigClassName & "' "
if SmallClassName<>"" then
sql=sql & " and SmallClassName='" & SmallClassName & "' "
end if
else
if SpecialName<>"" then
sql=sql & " and SpecialName='" & SpecialName & "' "
end if
end if
sql=sql & " order by articleid desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
%>
<SCRIPT language=javascript>
function unselectall()
{
if(document.del.chkAll.checked){
document.del.chkAll.checked = document.del.chkAll.checked&0;
}
}

function CheckAll(form)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.Name != "chkAll")
e.checked = form.chkAll.checked;
}
}
function ConfirmDel()
{
if(confirm("确定要删除选中的产品吗?一旦删除将不能恢复!"))
return true;
else
return false;

}

</SCRIPT>
<!-- #include file="Inc/Head.asp" -->
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
……
<td width="80" align="center" bgcolor="#ECF5FF"> <a href="ProductModify.asp?ArticleID=<%=rs("articleid")%>">修改</a>
<a href="ProductDel.asp?ArticleID=<%=rs("ArticleID")%>&Action=Del" onClick="return ConfirmDel();">删除</a>
</td>
</tr>
……
<td><input name="submit" type='submit' value='删除选定的产品' <%if session("purview")>=3 and session("purview")<=4 and PurviewChecked=False then response.write "disabled"%>>
<input name="Action" type="hidden" id="Action" value="Del"></td>
</tr>
</table>
……
另外在添加产品的程序中如何修改Product_Id这个函数按照自己的意愿按次序自动递增???

代码太长我没有看, 回答你后面这一个问题:
另外在添加产品的程序中如何修改Product_Id这个函数按照自己的意愿按次序自动递增???

你用的是什么数据库,如果是SQL Server那么找到Products表, 右键-设计表-Product_Id字段,选择》标识 为 "是" 保存即可.
access 找到Product_Id字段 数据类型 》 自动编号

rs.open sql,conn,1,1
改成rs.open sql,conn,1,3