请大虾们看看我的代码出了什么问题?

zhong3113 2003-09-14 02:08:20
asp+sql2000
为什么我不能把数据添加到数据库中,不知道下面的代码出了什么错~!请大虾门帮忙看看
谢谢了
首先是add_news.asp
<!--#include file="session.asp"-->
<!--#include file="conn.asp"-->
<html>
<head>
<title>填加新闻</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<link rel="stylesheet" href="../../css/style.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000" background="bkg.gif">
<form method="post" action="save_news.asp">
<table width="500" border="0" cellspacing="1" cellpadding="0" align="center">
<tr>
<td width="120" height="30" align="center">新闻标题:</td>
<td height="40">  
<input type="text" name="title" size="50" class="form" maxlength="100">
</td>
</tr>
<tr>
<td width="120" height="30" align="center">新闻类别:</td>
<td height="40">  
<select name="class" class="form">
<option selected value="">请选择新闻类别</option>
<%
dim rs,sql,sel,classname
set rs=server.createobject("adodb.recordset")
sql="select * from class"
rs.open sql,conn,1,1
do while not rs.eof
classname=rs("class")
if (rs("class"))="本地" then
classname="广州"
end if
response.write "<option value='"+CStr(rs("ClassID"))+"' name=class>"&classname&"新闻</option>"+chr(13)+chr(10)
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</select>
</td>
</tr>
<tr>
<td width="120" height="30" align="center">新闻内容:</td>
<td height="40">  
<textarea name="content" cols="48" rows="10" class="form"></textarea>
</td>
</tr>
<tr>
<td width="120" height="30" align="center">新闻图片:</td>
<td height="40">  
<input type="text" name="img" size="50" class="form">
</td>
</tr>
<tr>
<td width="120" height="30" align="center">新闻出处:</td>
<td height="40">  
<input type="text" name="fromto" size="50" class="form">
</td>
</tr>
<tr>
<td width="120" height="30" align="center">热点新闻:</td>
<td height="40"> 
<input type="checkbox" value="1" name="hot" checked>
<font color="#FF0000">(如果选择,那么该新闻为热点新闻)</font></td>
</tr>
<tr>
<td width="120" height="30" align="center">是否附图:</td>
<td height="40">  
<input type="checkbox" value="1" name="pic">
<font color="#FF0000">(如果选择,那么新闻就会在首页显示附图字样)</font></td>
</tr>
<tr align="center">
<td colspan="2" height="40">
<input type="submit" name="Submit" value="提交新闻" class="form">
  
<input type="reset" name="reset" value="重新填写" class="form">
</td>
</tr>
</table>
</form>
</body>
</html>


下面是save_news.asp的代码~~~!

<!--#include file="session.asp"-->
<!--#include file="conn.asp"-->
<!--#include file="../../inc/char.inc"-->
<%
dim action
action=request.form("action")
%>
<% if action="edit" then %>
<%
if request.form("title")="" then
response.write "<p align='center'>错误:新闻标题不能为空,请输入新闻标题!</p>"
response.write "<p align='center'><a href='javascript:history.back(1)'>返回重新输入</a>"
response.end
end if
if request.form("class")="" then
response.write "<p align='center'>错误:新闻类别没有选择!</p>"
response.write "<p align='center'><a href='javascript:history.back(1)'>返回重新输入</a>"
response.end
end if
if request.form("content")="" then
response.write "<p align='center'>错误:新闻内容不能为空,请输入新闻内容!</p>"
response.write "<p align='center'><a href='javascript:history.back(1)'>返回重新输入</a>"
response.end
end if

dim title
dim content
dim classid
dim img
dim pic
dim hot
dim fromto
dim sql
dim rs
dim NewsID

NewsID=request("NewsID")
title=request.form("title")
content=UBBCode(request.form("content"))
ClassID=request.form("class")
img=request.form("img")
fromto=request.form("fromto")
pic=request.form("pic")
hot=request.form("hot")
if request.form("fromto")="" then
from="好网"
end if

set rs=server.createobject("adodb.recordset")
sql="select * from news where NewsID="&NewsID

rs.open sql,conn,1,3
rs("title")=title
rs("content")=content
rs("ClassID")=ClassID
rs("img")=img
rs("fromto")=fromto
rs("pic")=pic
rs("hot")=hot
rs("timeto")=date()
rs.update

rs.close
set rs=nothing
%>
<% else %>
<%
if request.form("title")="" then
response.write "<p align='center'>错误:新闻标题不能为空,请输入新闻标题!</p>"
response.write "<p align='center'><a href='javascript:history.back(1)'>返回重新输入</a>"
response.end
end if
if request.form("class")="" then
response.write "<p align='center'>错误:新闻类别没有选择!</p>"
response.write "<p align='center'><a href='javascript:history.back(1)'>返回重新输入</a>"
response.end
end if
if request.form("content")="" then
response.write "<p align='center'>错误:新闻内容不能为空,请输入新闻内容!</p>"
response.write "<p align='center'><a href='javascript:history.back(1)'>返回重新输入</a>"
response.end
end if
%>
<%

title=request.form("title")
content=UBBCode(request.form("content"))
ClassID=request.form("class")
img=request.form("img")
fromto=request.form("fromto")
pic=request.form("pic")
hot=request.form("hot")
if request.form("fromto")="" then
from="好网"
end if

set rs=server.createobject("adodb.recordset")
sql="select * from news"

rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
rs("ClassID")=ClassID
rs("img")=img
rs("fromto")=fromto
rs("pic")=pic
rs("hot")=hot
rs("timeto")=date()
rs.update

rs.close
set rs=nothing
conn.close
set conn=nothing

%>
<% end if %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加成功</title>
<link rel="stylesheet" type="text/css" href="../../css/style.css">
</head>
<body>
<table width="400" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td align="center" height="22" class="font">恭喜!添加新闻成功!1秒后自动返回到新闻添加页面!</td>
</tr>
</table>
<meta http-equiv=refresh content="1; url=add_news.asp">
</body>
</html>

大虾们帮忙看看,谢谢了

...全文
30 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
AoioA 2003-09-15
  • 打赏
  • 举报
回复
问题很多罗:字段名是否写正确;提交表单数据类型是否一致;代码都检查正确了的话,看看看看表单重数据的宽度是否超出了数据库定义的宽度,等等,错误都不列出来,人家怎么帮你呢?!
萝卜波 2003-09-15
  • 打赏
  • 举报
回复
response.write err.description
把错误贴出来
形印声传 2003-09-14
  • 打赏
  • 举报
回复
too long~~~
zhong3113 2003-09-14
  • 打赏
  • 举报
回复
上面的就是关键的代码呀~!帮忙看看吧,谢谢了
lions911 2003-09-14
  • 打赏
  • 举报
回复
太长了,看不完,请给出关键代码!
现在很多做透明加解密的初学者都比较困惑,不知从何下手,我也是如此,从什么都不会开始,慢慢肯文件系统内幕,到OSR上面教,四个月的时间还是收获颇丰。其实真正研究以后会发现,很多都是体力活,要不断的去跟踪文件的操作流程。在这里发一个基于minifilter的透明加解密的驱动源码仅供大家参考,其中也实现了对文件标识的处理,文件标识放在文件尾部。算是抛砖引玉吧。坦白的说,这个代码并不稳定(偶尔与norton杀毒软件会有冲突),但是我觉得整个流程是正确的,可能有些细节还没有考虑清楚,我觉得对初学者还是有一定帮助吧,当然大虾们可以跳过,呵呵。另外,有关加解密算法的代码由于不是我写的,也不好公开,所以我把相关代码用“\\\”给注释掉了(但没有去掉),大家见谅,不过不会对整个流程产生影响。大家可以重点看一下各个派遣函数的实现。 欢迎大家拍砖,觉得有点意思就顶一下啊,在看代码的过程中如果有什么好的建议,也希望能告诉我。 最后非常感谢XiangXiangRen,zzbwang,neak47等网友在这段时间内对我的帮助。XiangXiangRen的书以及zzbwang的帖子对我完成这项工作有很大的帮助和参考价值,在此谨与大家分享。 编译环境:WDK6001.18002 XP x86 PS: 您可以将附件中的代码进行修改和转发,但转发时注明处。 http://bbs.driverdevelop.com/htm_data/39/1001/119736.html

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧