| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 545 人关注过本帖
标题:为什么我在后台添加或删减产品的时候出错,就是不能用啊。
只看楼主 加入收藏
karyson
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-6-25
收藏
 问题点数:0 回复次数:0 
为什么我在后台添加或删减产品的时候出错,就是不能用啊。
我的ASP源码为:
<%@language="VBscript"%>
<%Response.Expires=0%>
<!--#include file="../include/checkuser.asp"-->
<!--#include file="../include/upload.asp"-->
<!--#include file="../include/db_conn.asp"-->

<%
  function UpdateStr(str) '转化字符串
      'str = Replace(str,"'","’")
      'str = Replace(str,chr(34),"”")
      'str = replace(str,"<","&lt;")
    'str = replace(str,">","&gt;")
    'str = replace(str,chr(13),"<br>")
      UpdateStr = str
  end function


dim upload,file,sfilename,bfilename,formName,sPath,bPath,iCount
set upload=new upload_5xSoft ''建立上传对象

 sPath="../Prod_Photo/s/"'缩略图路径
 bPath="../Prod_Photo/b/"'产品图路径
 
 edit_type=upload.form("edit_action") '编辑类型
 type_id=upload.form("type_id")'产品二级分类ID
 current_ver=upload.form("current_ver") '当前的版本号
 
 is_top=upload.form("is_top")
  is_index=upload.form("is_index")
 
 if is_index="" then is_index="0"
 if is_top="" then is_top="0"
 if is_comm="" then is_comm="0"
%>


<%
if edit_type="add_new" then '当添加新产品时

          sqlstr="insert into t_product (type_id,me_ver,is_index,is_top,is_comm,is_hot,hot_txt) values("
          sqlstr=sqlstr & type_id & ",'" & current_ver & "','" & is_index & "','" & is_top & "','" & is_comm & "','"
          sqlstr=sqlstr & is_hot & "','" & hot_txt & "')"
         
          conn.execute sqlstr
         
         set rs = conn.Execute("SELECT top 1 productid FROM t_product ORDER BY productid DESC")
              if not rs.eof then
                  id = rs("productid")
              else
                  id = 1
              end if
          rs.close
         
          '上传图片
          '****************************************************************************************
                     
          set file=upload.file("small_photo") '上传缩缩图
              if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
                  sfilename=current_ver & "_s_" & catalogid & "_" & id & right(file.FileName,4)
                  file.SaveAs Server.mappath(sPath&sfilename)   ''保存文件                  
              end if         
        set file=nothing
         
          set file=upload.file("big_photo") '上传产品图片
              if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
                  bfilename=current_ver & "_b_" & catalogid & "_" & id & right(file.FileName,4)
                  file.SaveAs Server.mappath(bPath&bfilename)   ''保存文件                  
              end if         
        set file=nothing
         
          '****************************************************************************************
         
          set myrs=server.CreateObject("adodb.recordset")
          myrs.Open "select * from t_product where productid=" & id,conn,1,3  
      
      'save_me.asp文件为生成的不同分类产品的字段集
      %>
      <!--#include file="../include/save_me.asp"-->
      <%
         
                  'myrs("mak_price")=upload.form("mak_price")
                  'myrs("mem_price")=upload.form("mem_price")
                  'myrs("vip_price")=upload.form("vip_price")
                  myrs("small_photo")=sfilename
                  myrs("big_photo")=bfilename
                  
                  myrs.update
         
          myrs.Close
          set myrs=nothing
         
           
   
    session("current_type_id")=type_id '加入当前的产品分类

    title_str="添 加 产 品"
    msg_str="<b><font color=red>添加成功!</font></b><br><br>"
    msg_str=msg_str & "<a href='list_product.asp?version="& current_ver & "'>浏览产品</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='add_product.asp?version="& current_ver & "&catalogid=" & catalogid & "'>继续添加产品</a>"
    return_to_add  
   
   
elseif edit_type="edit" then '当修改产品时
  
  productid=upload.form("productid")  '取得要修改的新闻ID号
  
  state=upload.form("state")
 
  if state="1" then
   oos_txt=UpdateStr(upload.form("oos_txt"))
  else
   oos_txt=""
  end if
  
  set myrs=server.CreateObject("adodb.recordset")
  myrs.Open "select * from t_product where productid=" & productid,conn,1,3
   
      if myrs("small_photo")<>"" then del_s_photo=upload.form("del_s_photo") '更改缩略图片
         
          if del_s_photo="1" then
              sfilename=""
          else
              '上传图片
              '****************************************************************************************
                     
              set file=upload.file("small_photo") '上传缩缩图
                  if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
                      sfilename=current_ver & "_s_" & catalogid & "_" & productid & right(file.FileName,4)
                      file.SaveAs Server.mappath(sPath&sfilename)   ''保存文件                  
                  end if         
              set file=nothing
              
                  if sfilename="" then sfilename=myrs("small_photo")
              
              '****************************************************************************************               
          end if
         
              
      if myrs("big_photo")<>"" then del_b_photo=upload.form("del_b_photo") '更改产品图片
         
          if del_b_photo="1" then
              bfilename=""
          else
              '上传图片
              '****************************************************************************************
                     
              set file=upload.file("big_photo") '上传产品图片
                  if file.FileSize>0 then         ''如果 FileSize > 0 说明有文件数据
                      bfilename=current_ver & "_b_" & catalogid & "_" & productid & right(file.FileName,4)
                      file.SaveAs Server.mappath(bPath&bfilename)   ''保存文件                  
                  end if         
              set file=nothing
              
                  if bfilename="" then bfilename=myrs("big_photo")
              
              '****************************************************************************************               
          end if
         
      '开始更新数据
      
      myrs("type_id")=type_id
      myrs("is_index")=is_index
      myrs("is_top")=is_top
      myrs("is_comm")=is_comm
      myrs("is_hot")=is_hot
      myrs("hot_txt")=hot_txt
      myrs("state")=state
      myrs("oos_txt")=oos_txt
      myrs("last_date")=now()
      
      'save_me.asp文件为生成的不同分类产品的字段集
      %>
      <!--#include file="../include/save_me.asp"-->
      <%
  
                  'myrs("mak_price")=upload.form("mak_price")
                  'myrs("mem_price")=upload.form("mem_price")
                  'myrs("vip_price")=upload.form("vip_price")
                  myrs("small_photo")=sfilename
                  myrs("big_photo")=bfilename
                  
                  myrs.update
  
          myrs.Close
          set myrs=nothing   
  
  
  return_to_edit '返回修改页面
  'Response.Write session("current_productid")
  'Response.Write session("current_edit_page")+1

else
  title_str="非 法 操 作"
  msg_str="<b><font color=red>你执行了非法操作!</font></b>请返回<A href='javascript:history.back(1)'>.</A>"
  return_to_add
  
end if

set upload=nothing  ''删除此对象



%>

<%sub return_to_edit()%>

 <form action="edit_product.asp" method=post name="frm_page">
  <INPUT type="hidden" name="catalogid" value="<%=catalogid%>">
  <INPUT type="hidden" name="version" value="<%=current_ver%>">  
  <INPUT type="hidden" name="me_page" value=<%=session("current_edit_page")+1%>>
  <INPUT type="hidden" name="productid" value="<%=session("current_productid")%>">
</form>
<script language="javascript">
  document.frm_page.submit();
</script>
<%end sub%>

<%sub return_to_add()%><html>
<head>
<title><%=system_name%>_添加新产品</title>
<META NAME="robots" CONTENT="none">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css" type="text/css"></head>
<body bgcolor="#FFFFFF" leftMargin=0 marginwidth="0" topmargin=0>
<!--#include file="../include/header.asp"-->
<br>
<table width="700" border="0" cellspacing="1" cellpadding="1" bgcolor="#f0f0f0" align="center">
  <tr>
    <td>
      <table width="700" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr align="left">
          <td height="28" >&nbsp;&nbsp;<font face="webdings" color="#666666">8</font><a href="main.asp">回主菜单</a>
            <img src="../images/pixel.gif" width="235" height="1"><span style="FONT-SIZE: 14px"><b><font color="#666666"><%=title_str%></font></b></span></td>
        </tr>
        <tr align="center">
          <td height="120" bgcolor="#ffffff"><%=msg_str%></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td height="10"></td>
  </tr>
</table>
<br>
<!--#include file="../include/bottom.asp"-->
</body>
</html>
<%end sub%>

网页错误信息提示如下:

Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]无法将 NULL 值插入列 'productid',表 'karyson.karyson.t_product';该列不允许空值。INSERT 失败。

/karyson/pro/hypervisor/add_ok.asp,行 44

我看了下数据库中的表,productid这个字段是不允许为空的啊,
但事实这个网站在远程服务器上是能用的中了,我换了台服务器就不行了中了,为什么、????各位大全帮帮忙,不胜感激!
搜索更多相关主题的帖子: 后台 删减 
2008-06-25 17:17
快速回复:为什么我在后台添加或删减产品的时候出错,就是不能用啊。
数据加载中...
 
   



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

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