| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 825 人关注过本帖
标题:怎么插入不成功
只看楼主 加入收藏
威龙嘉少
Rank: 1
等 级:新手上路
帖 子:205
专家分:0
注 册:2007-9-24
收藏
 问题点数:0 回复次数:7 
怎么插入不成功
 我做了一个添加文章的页面,添加后提示成功了,没有出什么错,可是数据库里什么都没有?
是怎么回师啊,有知道的吗?指点下!谢谢
代码:
<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文章管理页面</title>
</head>
<!--#include file="conn.asp"-->
<%
if request.form("send")="发表" then
title=request.form("title")
neirong=request.form("Content")
author=request.form("author")
classid=request.form("class")
from=request.form("from")
response.Write(title)
response.Write(neirong)
response.Write(from)
conn.execute "insert into article(title,neirong,from,author,class,vtime) values('"&title&"','"&neirong&"','"&from&"','"&author&"',"&classid&",0)"
if conn.errors.count>0 then
   response.write("error")        
end if

response.write "<script language='javascript'>"
response.write "alert('添加成功!');"
response.write "location.href='javascript:history.go(-1)';"                            
response.write "</script>"
end if    
%>
<body text="#000000" topmargin="0" bgcolor="#009900">
<div align="center">
<!--#include file="top.asp"-->
<table border="0" cellpadding="0" cellspacing="0" height="485" width="810" background="image/beijing.jpg">
 <tr>
  <td width="5" height="500"></td>
  <td width="800" height="500" align="center" valign="top"><form id="form1" name="form1" method="post" action="">
    <table width="800" height="500" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="500" height="30" align="center">文章标题:
          <label>
          <input name="title" type="text" id="title" style="width:120px; height:20px; background-color:#E7F0F0; border:#CCFF00 1px dotted;" />
          </label></td>
        <td width="300" align="left">作者:
          <label>
          <input name="author" type="text" id="author" style="width:100px; height:20px; background-color:#E7F0F0; border:#CCFF00 1px dotted;" />
          </label></td>
      </tr>
      <tr>
        <td width="500" height="30" align="center">文章类别:
          <label>
          <select name="class" id="class">
            <option>-☆文章类别☆-</option>
            <option value="1">最新新闻</option>
            <option value="2">最新推荐</option>
            <option value="3">热点文章</option>
            <option value="4">情感天地</option>
          </select>
          </label></td>
        <td width="300" align="left"><label>来自:
          <input name="from" type="text" id="from" style="width:100px; height:20px; background-color:#E7F0F0; border:#CCFF00 1px dotted;" />
        </label>
          <label></label></td>
      </tr>
      <tr>
        <td height="440" colspan="2" align="center" valign="top">
            <textarea name="Content" id="Content" style="display:none"></textarea>
        <IFRAME ID="Content1" SRC="editor.asp?id=Content" FRAMEBORDER="0" SCROLLING="no" WIDTH="600" HEIGHT="425" align="middle"></IFRAME>
                <p align="center"><input type="submit" name="send" value="发表">
        </td>
      </tr>
    </table>
    </form>
  </td>
  <td width="5" height="500"></td>
 </tr>
</table>
<!--#include file="bottom.asp"-->
</div>  
</body>
</html>
搜索更多相关主题的帖子: 成功 html private PUBLIC 文章 
2007-12-12 20:18
letla
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-11-18
收藏
得分:0 
没有response.Update?
我是刚学ASP的啊。。。我也不太明白的。。。
2007-12-12 21:42
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
为什么要response.update?
程序代码:
if conn.errors.count>0 then
   response.write("error")        
end if

response.write "<script language='javascript'>"
response.write "alert('添加成功!');"
response.write "location.href='javascript:history.go(-1)';"                            
response.write "</script>"
end if     
这里,如果出错了(我估计就是出错了),会在屏幕上显示“error”,这没错,然后也显示了“添加成功”,而实际上没有添加成功,所以这里有设计的逻辑问题。
2007-12-12 21:47
威龙嘉少
Rank: 1
等 级:新手上路
帖 子:205
专家分:0
注 册:2007-9-24
收藏
得分:0 
那到底是哪里错了,改怎么改啊?
输出的时候有error,可是看不出有哪里不对啊 ?
2007-12-13 20:53
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
楼主使用的是什么数据库?Access检查文件是否只读,SQL Server检察账户是否有写入权限?
2007-12-13 21:55
letla
Rank: 1
等 级:新手上路
帖 子:137
专家分:0
注 册:2007-11-18
收藏
得分:0 
都说了我是刚学ASP吖。。。所以就以为添加或者修改数据都要用到update啊。。。
2007-12-14 08:22
madpbpl
Rank: 4
等 级:贵宾
威 望:11
帖 子:2876
专家分:244
注 册:2007-4-5
收藏
得分:0 
conn.execute "insert into article(title,neirong,from,author,class,vtime) values('"&title&"','"&neirong&"','"&from&"','"&author&"',"&classid&",0)"
改成
conn.execute "insert into article(title,neirong,[from],author,class,vtime) values('"&title&"','"&neirong&"','"&from&"','"&author&"',"&classid&",0)"
2007-12-14 11:02
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 
title,from,class 为什么总是要使用这样比较敏感的词语做字段名呢,一不小心就是数据库保留词了!

if conn.errors.count>0 then
   response.write("error")        
end if
里面加个 response.end 到此结束
if conn.errors.count>0 then
   response.write("error")
   response.end      
end if

这样就可以看到错了!
2007-12-14 14:08
快速回复:怎么插入不成功
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027097 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved