注册 登录
编程论坛 ASP技术论坛

为什么添加后台数据没有变化?

冰雪飘飘 发布于 2008-04-24 10:29, 1211 次点击
数据库中有一表feedback,其中recorder、backtime等是字段,想添加记录,
虽然能显示添加成功,但是后台数据没有变化,还有一个奇怪的现象,就是在删除一个已经后,再添加,偶而有能成功添加,我是一个新手,请个为老师多多请教!添加程序asp代码如下:
<%
IF Request.Form("action")="添加" Then
        Frecorder=trim(request("recorder"))
        Fbacktime=trim(request("backtime"))
        Fproduct=trim(request("product"))
        Fuser_name=trim(request("user_name"))
        Fpeople=trim(request("people"))
        Fcontent=trim(request("content"))
        Fhandle=trim(request("handle"))
        Fresult=trim(request("result"))
        set rsF=server.createobject("adodb.recordset")
        sqltext="select * from [feedback]"
        rsF.open sqltext,conn,3,3

    '添加一条记录到数据库
        rsF.addnew
        rsF("recorder")=Frecorder
        rsF("backtime")=Fbacktime
        rsF("product")=Fproduct
        rsF("user_name")=Fuser_name
        rsF("people")=Fpeople
        rsF("content")=Fcontent
        rsF("handle")=Fhandle
        rsF("result")=Fresult
        rsF.update
        rsF.close
        conn.close
        response.write "<script language=JavaScript>{window.alert('此信息添加成功!');opener.parent.right.location.href='Feedback.asp';window.close();}</script>"
        response.end

    
End If
%>
9 回复
#2
gaojing_abc2008-04-24 11:33
条件语句是想判断什么?
可能是IF语句的问题。
#3
冰雪飘飘2008-04-24 13:09
这是整个添加程序段:
<!--#include file="conn.asp"-->
<SCRIPT language=javascript>
function form4_onsubmit()
{
if(document.FORM4.recorder.value.length<1)
 {
   alert("经手人不能为空!");
   document.FORM4.recorder.focus();
   return false;
  }
   if(document.FORM4.content.value.length<1)
 {
   alert("反馈内容不能为空!");
   document.FORM4.content.focus();
   return false;
 }
}
</SCRIPT>
<%
IF Request.Form("action")="添加" Then
        Frecorder=trim(request("recorder"))
        Fbacktime=trim(request("backtime"))
        Fproduct=trim(request("product"))
        Fuser_name=trim(request("user_name"))
        Fpeople=trim(request("people"))
        Fcontent=trim(request("content"))
        Fhandle=trim(request("handle"))
        Fresult=trim(request("result"))
        set rsF=server.createobject("adodb.recordset")
        sqltext="select * from [feedback]"
        rsF.open sqltext,conn,3,3

    '添加一条记录到数据库
        rsF.addnew
        rsF("recorder")=Frecorder
        rsF("backtime")=Fbacktime
        rsF("product")=Fproduct
        rsF("user_name")=Fuser_name
        rsF("people")=Fpeople
        rsF("content")=Fcontent
        rsF("handle")=Fhandle
        rsF("result")=Fresult
        rsF.update
        rsF.close
        conn.close
        response.write "<script language=JavaScript>{window.alert('此信息添加成功!');opener.parent.right.location.href='Feedback.asp';window.close();}</script>"
        response.end

    
End If
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="Styles.css">
<title>添加反馈信息</title>
</head>
<body oncontextmenu=self.event.returnValue=false>

<form method="POST" action="Feedback_Add.asp" name='FORM4' onSubmit="return form4_onsubmit()">
<table border="1" cellpadding="0" width="100%" bordercolorlight="#A8CBF1" bordercolordark="#FFFFFF" cellspacing="0" height="66">
<tr>
<td colspan="2" bgcolor="#A8CBF1" height="30" align="center"><font size=3><b>添加反馈信息</font></b></td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">经手人:</td>
<td width="71%" bgcolor="#E9F4FF">
<input type="text" name="recorder" size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">反馈日期:</td>
<td width="71%" bgcolor="#E9F4FF">
<input name="backtime" type="text"size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">相关产品:</td>
<td width="71%" bgcolor="#E9F4FF">
<input name="product" type="text"  size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">相关客户:</td>
<td width="71%" bgcolor="#E9F4FF">
<input name="user_name" type="text" size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">相关联系人:</td>
<td width="71%" bgcolor="#E9F4FF">
<input name="people" type="text"  size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">反馈内容:</td>
<td width="71%" bgcolor="#E9F4FF">
  <input name="content" type="text" value="" size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">处理人员:</td>
<td width="71%" bgcolor="#E9F4FF">
  <input name="handle" type="text" value="" size="20">
</td>
</tr>
<tr>
<td width="32%" height="30" bgcolor="#E9F4FF" align="right">处理结果:</td>
<td width="71%" bgcolor="#E9F4FF">
  <input name="result" type="text" value="" size="20">
</td>
</tr>
<tr>
<td height="30" bgcolor="#E9F4FF" colspan="2" align="center">
<p align="center"><input class=button1 type="submit" value="添加" name="action">
  <INPUT class=button1 onclick=javascript:window.close() type=button value=关闭></p>
</td>
</tr>
</table></form>
</body>
</html>
#4
ysm1402008-04-24 13:39
<form method="POST" action="Feedback_Add.asp" name='FORM4' onSubmit="return form4_onsubmit()">
改成
<form method="POST" action="Feedback_Add.asp?action=添加" name='FORM4' onSubmit="return form4_onsubmit()">
#5
冰雪飘飘2008-04-24 14:37
不行啊!我也曾那样改过,可是改后连"此信息添加成功!"都没有显示了,窗口也没有关闭.
真是急死人了,为什么在这就不能实现呢?
#6
feelingxj2008-04-25 00:16
rsF.open sqltext,conn,1,3试试
#7
madpbpl2008-04-25 00:39
因为这句话
IF Request.Form("action")="添加" then
有问题
#8
multiple19022008-04-25 07:47
<p align="center"><input class=button1 type="submit" value="添加" name="submit"><input type="hidden" value="添加" name="action" />
  <INPUT class=button1 onclick=javascript:window.close() type=button value=关闭></p>


试试这个
#9
fengmumei2008-04-26 17:05
action="Feedback_Add.asp"中的“Feedback_Add.asp”就是你发上来的那段代码?
#10
冰雪飘飘2008-04-26 22:59
问题已经解决.真的麻烦各位了,谢谢你们!
我数据库设计有问题,真的很不好意思,我也是后面才发现的
1