学ASP一段时间了,自己试着写了段程序,经反复修改,目前还发现下述错误:
1、删除完所有歌曲记录后出现错误,无法正常显示页面。
2、添加歌曲记录时,当歌词栏字数超过50字时页面不能正常显示,歌词栏字数不超过50字时可以正常添加并写入数据库。
3、其他错误尚未发现,欢迎指出。
敬请指教,感激不尽!
程序代码如下:
<!--#include file="conn.asp"-->
<!--#include file="identify.asp"-->
<%
if Request("del")<>"" Then
Sql = "Delete From music2006 Where id="&request("del")
Conn.Execute(Sql)
Response.Redirect "manger.asp"
End if
if Request("action")="edit" then
Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select * from music2006 where id="&request("id")
rs.Open sql,conn,1,3
rs("filename")=trim(request("filename"))
rs("singer")=trim(request("singer"))
rs("dizi")=trim(request("dizi"))
rs("geci")=trim(request("geci"))
rs.Update
rs.Close
set rs=nothing
Response.Redirect "manger.asp"
end if
if Request("action")="add" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from music2006"
rs.open sql,conn,3,2
rs.addnew
if trim(request.form("filename"))="" then
response.write "<script language=javascript>"
response.write "alert('请填写歌曲名!');"
response.write "</script>"
response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
Response.End
end if
if trim(request.form("singer"))="" then
response.write "<script language=javascript>"
response.write "alert('请填写歌手名!');"
response.write "</script>"
response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
Response.End
end if
if trim(request.form("dizi"))="" then
response.write "<script language=javascript>"
response.write "alert('请填写歌曲地址!');"
response.write "</script>"
response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
Response.End
end if
if trim(request.form("geci"))="" then
response.write "<script language=javascript>"
response.write "alert('请填写歌曲歌词!');"
response.write "</script>"
response.write "<script language=javascript>location='javascript:history.back(1)'</script>"
Response.End
end if
rs("filename")=trim(request("filename"))
rs("singer")=trim(request("singer"))
rs("dizi")=trim(request("dizi"))
rs("geci")=trim(request("geci"))
rs.update
rs.close
response.redirect "manger.asp"
end if
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>管理界面</title>
<style type="text/css">
<!--
a:link {
text-decoration: none;
color: #000000;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #000000;
}
a:active {
text-decoration: none;
color: #000000;
}
body {
margin-top: 0px;
margin-bottom: 0px;
}
-->
</style>
</head>
<body>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="400" height="23" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="397" height="23" bgcolor="#99CC66"><div align="center"><strong>歌 曲 编 辑</strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><table width="400" height="22" border="1" cellpadding="0" cellspacing="0" bordercolor="#999966" bgcolor="#FFFFFF">
<tr>
<th width="404" height="20" bgcolor="#99CCCC" scope="col">
<table width="395" border="1" cellpadding="0" cellspacing="0">
<tr bgcolor="#99CCFF">
<td width="70" height="18" align="center"><strong>歌曲名</strong></td>
<td width="46" align="center"><strong>歌手名</strong></td>
<td width="66" align="center"><strong>路径名</strong></td>
<td width="136" align="center"><strong>歌 曲 词</strong></td>
<td width="65" align="center"><strong>操作类</strong></td>
</tr>
<%strPage=Request.queryString("page")
set rs=Server.CreateObject("adodb.recordset")
sql="SELECT * from music2006 order by id desc"
rs.open sql,conn,1,1
if rs.RecordCount>0 then
sumcount=rs.RecordCount
rs.MoveFirst
end if
rs.PageSize=5
intPageCount=rs.PageCount
if Len(strPage)=0 then strPage="1"
if int(strPage)=<1 then strPage="1"
if int(strPage)>=intPageCount then strPage=intPageCount
rs.absolutepage=cint(strPage)
if rs.bof then
response.Redirect("manger.asp")
end if
for i = 1 to rs.pagesize
%>
<tr>
<form action="manger.asp?action=edit" method="post">
<td width="70" height="18" align="center"><input name="filename" type="text" value="<%=rs("filename")%>" size="10"></td>
<td width="46" align="center"><input name="singer" type="text" value="<%=rs("singer")%>" size="6"><input name="id" type="hidden" id="id" value="<%=rs("id")%>"></td>
<td width="66" align="center"><input name="dizi" type="text" value="<%=rs("dizi")%>" size="9"></td>
<td width="136" align="center"><input name="geci" type="text" value="<%=rs("geci")%>" size="17"></td>
<td width="65" align="center"><input name="Submit" type="submit" class="button1" value="改"><a href="manger.asp?del=<%=rs("id")%>">删</a></td>
</form>
</tr>
<%
rs.movenext
if rs.eof then
i = i + 1
exit for
end if
next
%>
</table>
</tr>
</table></td>
</tr>
<tr>
<td height="21" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="400" height="21" bgcolor="#99CCFF">
<div align="center">
<% response.write "<font>页次:<font class=ver>"&strPage&"</font>/"&intPageCount&"页</font> "
if strPage=1 then
Response.write"首页 "
Response.write"上页 "
else
Response.write"<a href=manger.asp?page=1>首页</a> "
Response.write"<a href=manger.asp?page="+cstr(strPage-1)+">上页</a> "
end if
if strPage=intPageCount then
Response.write"下页 "
Response.write"末页"
else
Response.write"<a href=manger.asp?page="+cstr(strPage+1)+">下页</a> "
Response.write"<a href=manger.asp?page="+cstr(intPageCount)+">末页</a>"
end if
%>
</div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="24" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="400" height="24" bgcolor="#99CC66"><div align="center"><strong>添 加 新 歌</strong></div></td>
</tr>
</table></td>
</tr>
<form action="manger.asp?action=add" method="post" name="form" >
<tr>
<td height="12" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="400" height="12"><table width="400" border="1" cellpadding="0" cellspacing="0" bordercolor="#999966" bgcolor="#FFFFFF">
<tr>
<th width="82" scope="row"> 歌曲信息</th>
<td width="322"> 歌曲名
<input name="filename" type="text" size="13"> 歌手名
<input name="singer" type="text" size="13"></td>
</tr>
<tr>
<th width="82" scope="row">歌曲路径</th>
<td> <input name="dizi" type="text" size="42" value="mp3/.mp3"></td>
</tr>
<tr>
<th width="82" height="109" bgcolor="#FFFFFF" scope="row">歌曲歌词</th>
<td bgcolor="#FFFFFF"> <textarea name="geci" cols="41" rows="7">歌曲信息歌曲信息歌曲信息歌曲信息歌曲信息歌曲信息歌曲信息歌曲信息歌曲信息歌曲信息</textarea></td>
</tr>
</table>
</td>
</tr>
</table></td>
</tr>
<% rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<tr>
<td width="410" height="20" bgcolor="#99CC66"><div align="center">
<input type="submit" name="Submit3" value="添加">
<input type="reset" name="Submit2" value="清除">
</div></td>
</tr>
</form>
<tr>
<td height="20" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="400" height="23" bgcolor="#99CCFF"><div align="center">程序设计:Kirind Studio <a href="index.asp" target="_self">[退出管理]</a></div></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>