请大虾们看看我的代码出了什么问题?
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>
大虾们帮忙看看,谢谢了