表 information 现有 2721 条记录
现发布一亲新闻,向表中添加一条记录。
添加后连接对象中无错误,表中的记录条数加 1 成为 2711.
关闭连接对象,再打开表中的记录条数加 1,还是 2722.
当从其它的页面中查看结果时数据记录条数为 2721
再从打开添加新闻的页面表 information 现有 2721 条记录
所以现象是:新闻添加成功但页面上没有。
这是什么原因啊,请高手指教。
7 个解决方案
#1
你的ASP程序中如何进行更新的?代码是什么?
#2
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!--#include file="Admin_check.asp"-->
<html>
<head>
<title>中国硅铁贸易网管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Admin_Style.css">
</head>
<%
Function HtmlEncode(Str)'简单并且起到容错的功能,
If IsNull(Str) Then
Str=""
End If
HtmlEncode=Server.HtmlEncode(Str)
End Function%>
<script>
function checkForm()
{
if (document.pub_news.newsclass.value=="")
{
alert("请选择信息类型!");
document.pub_news.newsclass.focus();
return(false);
}
if (document.pub_news.newstitle.value=="")
{
alert("文章标题不能为空!");
document.pub_news.newstitle.focus();
return(false);
}
reture(true);
}
</script>
<%dim newsclass,s0,s1,s2,s3,s4
newsclass=request.querystring("class")
if newsclass=0 then s0="selected"
if newsclass="1" then s1="selected"
if newsclass="2" then s2="selected"
if newsclass="3" then s3="selected"
if newsclass="4" then s4="selected"
%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
<tr align="center">
<td height=25 colspan=2 class="topbg"><strong>发 布 导 航</strong></tr>
<tr>
<td width="100" class="tdbg" height=23><strong>发布类别:</strong></td>
<td class="tdbg"><a href="pub_news.asp?class=0">行业新闻</a> |
<a href="pub_news.asp?class=1">市场行情</a> |
<a href="pub_news.asp?class=2">统计资料</a> |
<a href="pub_news.asp?class=3">政策法规</a> |
<a href="pub_news.asp?class=4">本站动态</a></td>
</tr>
</table>
<br>
<form action="pub_news.asp" method="post" name="pub_news" onsubmit="return checkForm(pub_news)">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" height="454">
<tr class="title">
<td height="22" align="center" colspan=2><strong>资 讯 发 布</strong></td>
</tr>
<tr><td align=left class="tdbg" height="25">
<p align="right"> 资讯类别:</td>
<td class="tdbg" height="25">
<select name="newsclass">
<option>请选择信息类型</option>
<option value="行业新闻" <%=s0%>>· 行业新闻 ·</option>
<option value="市场行情" <%=s1%>>· 市场行情 ·</option>
<option value="统计资料" <%=s2%>>· 统计资料 ·</option>
<option value="政策法规" <%=s3%>>· 政策法规 ·</option>
<option value="本站动态" <%=s4%>>· 本站动态 ·</option>
</select>
</td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章标题:</td>
<td class="tdbg" height="25"> <input type="text" name="newstitle" size="37"> </td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章作者:</td>
<td class="tdbg" height="25"> <input type="text" name="newsauthor" size="37"> </td></tr>
<tr><td class="tdbg" align=left valign=top height="323">
<p align="right"> 正文内容:</td><td class="tdbg" height="323"> <textarea class="scolor" rows="2" name="newscontent" cols="20" style="display:none;width:100%;height:338px; line-height:150%; background-image:url('images/post_line.gif')"><%=HtmlEncode(Trim(Content))%></textarea>
<iframe src="editor/editor.htm?form=pub_news&edit=newscontent" style="width:90%;height:322px;border:0px none;background-image:url('images/post_line.gif')" scrolling="no" name="I1" border="0" frameborder="0" id="WebEditor"></iframe></td>
</td></tr>
<tr class="tdbg">
<td height="21" align="center" colspan=2><input type="submit" name="add" value="添 加" style="cursor:hand;" class=a2> <input type="reset" name="cancel" value="重 置" style="cursor:hand;" class=a2></td></tr>
</table></form>
<%If Request.ServerVariables("Content_Length") > 100 Then
'response.write Request.ServerVariables("Content_Length")
dim category,title,author,content,rs,sql
category=request.form("newsclass")
category=replace(category,"'","''")
title=request.form("newstitle")
title=replace(title,"'","''")
author=request.form("newsauthor")
author=replace(author,"'","''")
content=Trim(request.form("newscontent"))
content=replace(content,"'","''")
content=replace(content,vbcrlf,"<Br>" & vbcrlf)
set rs=server.createobject("adodb.recordset")
sql="select * from information"
rs.open sql,conn,1,3
rs.addnew
rs("category")=category
rs("title")=title
rs("author")=author
rs("content")=content
rs("pubdate")=Now()
rs("istop")=true
rs.update
rs.close
set rs=nothing
call closeconn()%>
<script language="JavaScript" type="text/JavaScript">
alert("信息发布成功!");
</script>
<%
else
end if%>
<script language="javascript">
window.opener.document.location.reload();
window.close();
</script>
</body>
</html>
<!--#include file="inc/conn.asp"-->
<!--#include file="Admin_check.asp"-->
<html>
<head>
<title>中国硅铁贸易网管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Admin_Style.css">
</head>
<%
Function HtmlEncode(Str)'简单并且起到容错的功能,
If IsNull(Str) Then
Str=""
End If
HtmlEncode=Server.HtmlEncode(Str)
End Function%>
<script>
function checkForm()
{
if (document.pub_news.newsclass.value=="")
{
alert("请选择信息类型!");
document.pub_news.newsclass.focus();
return(false);
}
if (document.pub_news.newstitle.value=="")
{
alert("文章标题不能为空!");
document.pub_news.newstitle.focus();
return(false);
}
reture(true);
}
</script>
<%dim newsclass,s0,s1,s2,s3,s4
newsclass=request.querystring("class")
if newsclass=0 then s0="selected"
if newsclass="1" then s1="selected"
if newsclass="2" then s2="selected"
if newsclass="3" then s3="selected"
if newsclass="4" then s4="selected"
%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
<tr align="center">
<td height=25 colspan=2 class="topbg"><strong>发 布 导 航</strong></tr>
<tr>
<td width="100" class="tdbg" height=23><strong>发布类别:</strong></td>
<td class="tdbg"><a href="pub_news.asp?class=0">行业新闻</a> |
<a href="pub_news.asp?class=1">市场行情</a> |
<a href="pub_news.asp?class=2">统计资料</a> |
<a href="pub_news.asp?class=3">政策法规</a> |
<a href="pub_news.asp?class=4">本站动态</a></td>
</tr>
</table>
<br>
<form action="pub_news.asp" method="post" name="pub_news" onsubmit="return checkForm(pub_news)">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" height="454">
<tr class="title">
<td height="22" align="center" colspan=2><strong>资 讯 发 布</strong></td>
</tr>
<tr><td align=left class="tdbg" height="25">
<p align="right"> 资讯类别:</td>
<td class="tdbg" height="25">
<select name="newsclass">
<option>请选择信息类型</option>
<option value="行业新闻" <%=s0%>>· 行业新闻 ·</option>
<option value="市场行情" <%=s1%>>· 市场行情 ·</option>
<option value="统计资料" <%=s2%>>· 统计资料 ·</option>
<option value="政策法规" <%=s3%>>· 政策法规 ·</option>
<option value="本站动态" <%=s4%>>· 本站动态 ·</option>
</select>
</td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章标题:</td>
<td class="tdbg" height="25"> <input type="text" name="newstitle" size="37"> </td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章作者:</td>
<td class="tdbg" height="25"> <input type="text" name="newsauthor" size="37"> </td></tr>
<tr><td class="tdbg" align=left valign=top height="323">
<p align="right"> 正文内容:</td><td class="tdbg" height="323"> <textarea class="scolor" rows="2" name="newscontent" cols="20" style="display:none;width:100%;height:338px; line-height:150%; background-image:url('images/post_line.gif')"><%=HtmlEncode(Trim(Content))%></textarea>
<iframe src="editor/editor.htm?form=pub_news&edit=newscontent" style="width:90%;height:322px;border:0px none;background-image:url('images/post_line.gif')" scrolling="no" name="I1" border="0" frameborder="0" id="WebEditor"></iframe></td>
</td></tr>
<tr class="tdbg">
<td height="21" align="center" colspan=2><input type="submit" name="add" value="添 加" style="cursor:hand;" class=a2> <input type="reset" name="cancel" value="重 置" style="cursor:hand;" class=a2></td></tr>
</table></form>
<%If Request.ServerVariables("Content_Length") > 100 Then
'response.write Request.ServerVariables("Content_Length")
dim category,title,author,content,rs,sql
category=request.form("newsclass")
category=replace(category,"'","''")
title=request.form("newstitle")
title=replace(title,"'","''")
author=request.form("newsauthor")
author=replace(author,"'","''")
content=Trim(request.form("newscontent"))
content=replace(content,"'","''")
content=replace(content,vbcrlf,"<Br>" & vbcrlf)
set rs=server.createobject("adodb.recordset")
sql="select * from information"
rs.open sql,conn,1,3
rs.addnew
rs("category")=category
rs("title")=title
rs("author")=author
rs("content")=content
rs("pubdate")=Now()
rs("istop")=true
rs.update
rs.close
set rs=nothing
call closeconn()%>
<script language="JavaScript" type="text/JavaScript">
alert("信息发布成功!");
</script>
<%
else
end if%>
<script language="javascript">
window.opener.document.location.reload();
window.close();
</script>
</body>
</html>
#3
在代码中打印的输出,但最后那个就是保存不上:
添加前的行数:2721
添加后的行数:2722
输出刚添加的结果:
1:3826;管理员测试;2008-6-18 19:31:33
2:3828;2008年5月份全国分省市铁合金产量统计;2008-6-19 9:09:22
...........
2719:6654;江油成功引进40万吨富锰渣项;2009-8-19 11:01:20
2720:6655;电光冶金(宿州)有限公司第一条高铬生产线正式投产;2009-8-19 11:02:43
2721:6657;钦北经济化危为机稳步发展;2009-8-19 11:11:10
2722:6785;管理员测试;2009-8-22 10:42:35
重新打开的行数:2722
添加前的行数:2721
添加后的行数:2722
输出刚添加的结果:
1:3826;管理员测试;2008-6-18 19:31:33
2:3828;2008年5月份全国分省市铁合金产量统计;2008-6-19 9:09:22
...........
2719:6654;江油成功引进40万吨富锰渣项;2009-8-19 11:01:20
2720:6655;电光冶金(宿州)有限公司第一条高铬生产线正式投产;2009-8-19 11:02:43
2721:6657;钦北经济化危为机稳步发展;2009-8-19 11:11:10
2722:6785;管理员测试;2009-8-22 10:42:35
重新打开的行数:2722
#4
请查看 其他页面上的 ASP 代码...找到显示记录条数控件的数据来源... 再判断原因...
#5
我已经把数据库下载下来看了数据库中没有新添加的内容。数据有500MB。
#6
应该是插入(insert)吧!怎么是update呢!
#7
使用insert命令,应该可以实现
#1
你的ASP程序中如何进行更新的?代码是什么?
#2
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="inc/conn.asp"-->
<!--#include file="Admin_check.asp"-->
<html>
<head>
<title>中国硅铁贸易网管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Admin_Style.css">
</head>
<%
Function HtmlEncode(Str)'简单并且起到容错的功能,
If IsNull(Str) Then
Str=""
End If
HtmlEncode=Server.HtmlEncode(Str)
End Function%>
<script>
function checkForm()
{
if (document.pub_news.newsclass.value=="")
{
alert("请选择信息类型!");
document.pub_news.newsclass.focus();
return(false);
}
if (document.pub_news.newstitle.value=="")
{
alert("文章标题不能为空!");
document.pub_news.newstitle.focus();
return(false);
}
reture(true);
}
</script>
<%dim newsclass,s0,s1,s2,s3,s4
newsclass=request.querystring("class")
if newsclass=0 then s0="selected"
if newsclass="1" then s1="selected"
if newsclass="2" then s2="selected"
if newsclass="3" then s3="selected"
if newsclass="4" then s4="selected"
%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
<tr align="center">
<td height=25 colspan=2 class="topbg"><strong>发 布 导 航</strong></tr>
<tr>
<td width="100" class="tdbg" height=23><strong>发布类别:</strong></td>
<td class="tdbg"><a href="pub_news.asp?class=0">行业新闻</a> |
<a href="pub_news.asp?class=1">市场行情</a> |
<a href="pub_news.asp?class=2">统计资料</a> |
<a href="pub_news.asp?class=3">政策法规</a> |
<a href="pub_news.asp?class=4">本站动态</a></td>
</tr>
</table>
<br>
<form action="pub_news.asp" method="post" name="pub_news" onsubmit="return checkForm(pub_news)">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" height="454">
<tr class="title">
<td height="22" align="center" colspan=2><strong>资 讯 发 布</strong></td>
</tr>
<tr><td align=left class="tdbg" height="25">
<p align="right"> 资讯类别:</td>
<td class="tdbg" height="25">
<select name="newsclass">
<option>请选择信息类型</option>
<option value="行业新闻" <%=s0%>>· 行业新闻 ·</option>
<option value="市场行情" <%=s1%>>· 市场行情 ·</option>
<option value="统计资料" <%=s2%>>· 统计资料 ·</option>
<option value="政策法规" <%=s3%>>· 政策法规 ·</option>
<option value="本站动态" <%=s4%>>· 本站动态 ·</option>
</select>
</td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章标题:</td>
<td class="tdbg" height="25"> <input type="text" name="newstitle" size="37"> </td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章作者:</td>
<td class="tdbg" height="25"> <input type="text" name="newsauthor" size="37"> </td></tr>
<tr><td class="tdbg" align=left valign=top height="323">
<p align="right"> 正文内容:</td><td class="tdbg" height="323"> <textarea class="scolor" rows="2" name="newscontent" cols="20" style="display:none;width:100%;height:338px; line-height:150%; background-image:url('images/post_line.gif')"><%=HtmlEncode(Trim(Content))%></textarea>
<iframe src="editor/editor.htm?form=pub_news&edit=newscontent" style="width:90%;height:322px;border:0px none;background-image:url('images/post_line.gif')" scrolling="no" name="I1" border="0" frameborder="0" id="WebEditor"></iframe></td>
</td></tr>
<tr class="tdbg">
<td height="21" align="center" colspan=2><input type="submit" name="add" value="添 加" style="cursor:hand;" class=a2> <input type="reset" name="cancel" value="重 置" style="cursor:hand;" class=a2></td></tr>
</table></form>
<%If Request.ServerVariables("Content_Length") > 100 Then
'response.write Request.ServerVariables("Content_Length")
dim category,title,author,content,rs,sql
category=request.form("newsclass")
category=replace(category,"'","''")
title=request.form("newstitle")
title=replace(title,"'","''")
author=request.form("newsauthor")
author=replace(author,"'","''")
content=Trim(request.form("newscontent"))
content=replace(content,"'","''")
content=replace(content,vbcrlf,"<Br>" & vbcrlf)
set rs=server.createobject("adodb.recordset")
sql="select * from information"
rs.open sql,conn,1,3
rs.addnew
rs("category")=category
rs("title")=title
rs("author")=author
rs("content")=content
rs("pubdate")=Now()
rs("istop")=true
rs.update
rs.close
set rs=nothing
call closeconn()%>
<script language="JavaScript" type="text/JavaScript">
alert("信息发布成功!");
</script>
<%
else
end if%>
<script language="javascript">
window.opener.document.location.reload();
window.close();
</script>
</body>
</html>
<!--#include file="inc/conn.asp"-->
<!--#include file="Admin_check.asp"-->
<html>
<head>
<title>中国硅铁贸易网管理系统</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="Admin_Style.css">
</head>
<%
Function HtmlEncode(Str)'简单并且起到容错的功能,
If IsNull(Str) Then
Str=""
End If
HtmlEncode=Server.HtmlEncode(Str)
End Function%>
<script>
function checkForm()
{
if (document.pub_news.newsclass.value=="")
{
alert("请选择信息类型!");
document.pub_news.newsclass.focus();
return(false);
}
if (document.pub_news.newstitle.value=="")
{
alert("文章标题不能为空!");
document.pub_news.newstitle.focus();
return(false);
}
reture(true);
}
</script>
<%dim newsclass,s0,s1,s2,s3,s4
newsclass=request.querystring("class")
if newsclass=0 then s0="selected"
if newsclass="1" then s1="selected"
if newsclass="2" then s2="selected"
if newsclass="3" then s3="selected"
if newsclass="4" then s4="selected"
%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0">
<table cellpadding="2" cellspacing="1" border="0" width="100%" class="border" align=center>
<tr align="center">
<td height=25 colspan=2 class="topbg"><strong>发 布 导 航</strong></tr>
<tr>
<td width="100" class="tdbg" height=23><strong>发布类别:</strong></td>
<td class="tdbg"><a href="pub_news.asp?class=0">行业新闻</a> |
<a href="pub_news.asp?class=1">市场行情</a> |
<a href="pub_news.asp?class=2">统计资料</a> |
<a href="pub_news.asp?class=3">政策法规</a> |
<a href="pub_news.asp?class=4">本站动态</a></td>
</tr>
</table>
<br>
<form action="pub_news.asp" method="post" name="pub_news" onsubmit="return checkForm(pub_news)">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="border" height="454">
<tr class="title">
<td height="22" align="center" colspan=2><strong>资 讯 发 布</strong></td>
</tr>
<tr><td align=left class="tdbg" height="25">
<p align="right"> 资讯类别:</td>
<td class="tdbg" height="25">
<select name="newsclass">
<option>请选择信息类型</option>
<option value="行业新闻" <%=s0%>>· 行业新闻 ·</option>
<option value="市场行情" <%=s1%>>· 市场行情 ·</option>
<option value="统计资料" <%=s2%>>· 统计资料 ·</option>
<option value="政策法规" <%=s3%>>· 政策法规 ·</option>
<option value="本站动态" <%=s4%>>· 本站动态 ·</option>
</select>
</td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章标题:</td>
<td class="tdbg" height="25"> <input type="text" name="newstitle" size="37"> </td></tr>
<tr><td class="tdbg" align=left height="27">
<p align="right"> 文章作者:</td>
<td class="tdbg" height="25"> <input type="text" name="newsauthor" size="37"> </td></tr>
<tr><td class="tdbg" align=left valign=top height="323">
<p align="right"> 正文内容:</td><td class="tdbg" height="323"> <textarea class="scolor" rows="2" name="newscontent" cols="20" style="display:none;width:100%;height:338px; line-height:150%; background-image:url('images/post_line.gif')"><%=HtmlEncode(Trim(Content))%></textarea>
<iframe src="editor/editor.htm?form=pub_news&edit=newscontent" style="width:90%;height:322px;border:0px none;background-image:url('images/post_line.gif')" scrolling="no" name="I1" border="0" frameborder="0" id="WebEditor"></iframe></td>
</td></tr>
<tr class="tdbg">
<td height="21" align="center" colspan=2><input type="submit" name="add" value="添 加" style="cursor:hand;" class=a2> <input type="reset" name="cancel" value="重 置" style="cursor:hand;" class=a2></td></tr>
</table></form>
<%If Request.ServerVariables("Content_Length") > 100 Then
'response.write Request.ServerVariables("Content_Length")
dim category,title,author,content,rs,sql
category=request.form("newsclass")
category=replace(category,"'","''")
title=request.form("newstitle")
title=replace(title,"'","''")
author=request.form("newsauthor")
author=replace(author,"'","''")
content=Trim(request.form("newscontent"))
content=replace(content,"'","''")
content=replace(content,vbcrlf,"<Br>" & vbcrlf)
set rs=server.createobject("adodb.recordset")
sql="select * from information"
rs.open sql,conn,1,3
rs.addnew
rs("category")=category
rs("title")=title
rs("author")=author
rs("content")=content
rs("pubdate")=Now()
rs("istop")=true
rs.update
rs.close
set rs=nothing
call closeconn()%>
<script language="JavaScript" type="text/JavaScript">
alert("信息发布成功!");
</script>
<%
else
end if%>
<script language="javascript">
window.opener.document.location.reload();
window.close();
</script>
</body>
</html>
#3
在代码中打印的输出,但最后那个就是保存不上:
添加前的行数:2721
添加后的行数:2722
输出刚添加的结果:
1:3826;管理员测试;2008-6-18 19:31:33
2:3828;2008年5月份全国分省市铁合金产量统计;2008-6-19 9:09:22
...........
2719:6654;江油成功引进40万吨富锰渣项;2009-8-19 11:01:20
2720:6655;电光冶金(宿州)有限公司第一条高铬生产线正式投产;2009-8-19 11:02:43
2721:6657;钦北经济化危为机稳步发展;2009-8-19 11:11:10
2722:6785;管理员测试;2009-8-22 10:42:35
重新打开的行数:2722
添加前的行数:2721
添加后的行数:2722
输出刚添加的结果:
1:3826;管理员测试;2008-6-18 19:31:33
2:3828;2008年5月份全国分省市铁合金产量统计;2008-6-19 9:09:22
...........
2719:6654;江油成功引进40万吨富锰渣项;2009-8-19 11:01:20
2720:6655;电光冶金(宿州)有限公司第一条高铬生产线正式投产;2009-8-19 11:02:43
2721:6657;钦北经济化危为机稳步发展;2009-8-19 11:11:10
2722:6785;管理员测试;2009-8-22 10:42:35
重新打开的行数:2722
#4
请查看 其他页面上的 ASP 代码...找到显示记录条数控件的数据来源... 再判断原因...
#5
我已经把数据库下载下来看了数据库中没有新添加的内容。数据有500MB。
#6
应该是插入(insert)吧!怎么是update呢!
#7
使用insert命令,应该可以实现