| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1303 人关注过本帖
标题:[求助]ASP中提交给数据库的记录都为空
只看楼主 加入收藏
modigliani
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-8-21
收藏
得分:0 
这样吧,我把zjxx.asp和tj.asp的原版代码发出来,你帮我把核心的部分改改好吧?
2006-08-21 11:57
modigliani
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-8-21
收藏
得分:0 
不需要验证用户的。
jzxx.asp代码

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file=conn1.asp -->
<HTML><HEAD><TITLE>淄博卫生</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="images/style.css" type=text/css rel=stylesheet>
<STYLE type=text/css>
.main_tab {
    BORDER-RIGHT: gray 0px solid; BORDER-LEFT: #ffffff 0px solid; COLOR: #000000; BORDER-BOTTOM: gray 0px solid;

BACKGROUND-COLOR: #d4d0c8
}
body {
    background-image: url(images/bg10.gif);
}
.STYLE3 {
    font-size: 14px;
    font-weight: normal;
}
.style4 {
    font-size: 16px;
    font-family: "黑体";
}
.style5 {color: #FF0000}
.style7 {font-size: 16px}
.style8 {font-weight: bold; font-family: "黑体";}
.style10 {font-size: 14}
</STYLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<script type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</HEAD>
<BODY bgColor=#474747 leftMargin=0 topMargin=0>
 <!-- #include file="TOP.asp" -->
<TABLE cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#ffffff border=0>
  <TBODY>
    <TR>
      <TD vAlign=top align=left colSpan=6 height=4></TD>
    </TR>
    <TR>
      <TD vAlign=top align=left width=72 height=100><SCRIPT language=javascript>
function newWin(url){
    window.open(url,"_blank","");

}
function  search(){
    var sKeyword = keyword.value
    if (sKeyword == ""){
        alert("输入的关键词不能为空!")
        return ;
    }
    var sCategory = category.value;
    var sPath = "../znss/index.asp?keyword="+ sKeyword+"&category="+sCategory;
    var sPath = "../znss/index.asp?keyword="+ sKeyword
    newWin(sPath)

}

document.onkeydown=function(){
   
    if (event.keyCode!=13) return
   
    if (event.srcElement.name=="textfield"){
        search();
    }
    else{
        event.keyCode=9
    }
}
</SCRIPT>
      </TD>
      <TD vAlign=top align=left colSpan=3></TD>
      <TD vAlign=top align=left width=657 height=100><TABLE height="311%" cellSpacing=0 cellPadding=0 width=601 border=0>
        <TBODY>
          <TR>
            <TD height="13"><p class="style7"><br>
                <span class="style8">局长信箱:</span></p>
              <p class="STYLE3">   感谢您对淄博市卫生工作的关心,请提出您的意见或建议。
                  <br>
                  <br>
                   注:(*)为必添项目</p>
              <form name="form1" method="post" action="tj.asp" encType=text/plain >
              <table width="512" height="314" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td width="131" align="center" class="STYLE3">
                    <label>姓名:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Name" type="text" id="Name" size="33">
                    *</td>
                </tr>
                <tr>
                  <td align="center" class="STYLE3">
                    <label>单位:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Unit" type="text" id="Unit" size="33">
                    *</td>
                </tr>
                <tr>
                  <td align="center" class="STYLE3">
                    <label>地址:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Adress" type="text" id="Adress" size="33">
                      *</td>
                </tr>
                <tr>
                  <td align="center" class="STYLE3">
                    <label>电话:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Phone" type="text" id="Phone" size="33">
                  </td>
                </tr>
                <tr>
                  <td align="center" class="STYLE3">
                    <label>传真:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Fax" type="text" id="Fax" size="33">
                  </td>
                </tr>
                <tr>
                  <td align="center" class="STYLE3">
                    <label>电子邮件:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Email" type="text" id="Email" size="33">
                    *</td>
                </tr>
                <tr>
                  <td align="center" class="STYLE3">
                    <label>其它联系方式:</label>
                  </td>
                  <td colspan="2" class="STYLE3">
                    <input name="Others" type="text" id="Others" size="33">
                  </td>
                </tr>
                <tr>
                  <td height="102" align="center" class="STYLE3">
                    <label>你的意见:</label>
                  </td>
                  <td height="102" colspan="2" class="STYLE3">
                    <textarea name="Message" cols="37" rows="10" id="Message"></textarea>
</td>
                </tr>
                <tr>
                  <td height="18" align="center"> </td>
                  <td width="227" height="18" align="left" class="STYLE3">
                    <input name="submit2" type="submit" id="queding2" value="确定">
                  </td>
                  <td width="154" align="left" class="STYLE3">
                    <input name="chongzhi" type="reset" id="chongzhi" value="重置">
                  </td>
                </tr>
                <tr>
                  <td height="16" colspan="3" align="center"> </td>
                </tr>
                <tr>
                  <td height="14" colspan="3" align="center"> </td>
                </tr>
              </table>
              </form>
              <p class="STYLE3"> </p>
              <p class="STYLE3"> </p></TD>
          </TR>
          <TR>
            <TD vAlign=center align=middle background=images/body_02.gif
          height=13> </TD>
          </TR>
          <TR>
            <TD vAlign=top align=middle background=义乌市卫生局.files/body_02.gif
          height=4><IMG height=4 src="images/body_line.gif"
        width=588></TD>
          </TR>
          <TR>
            <TD background=义乌市卫生局.files/body_02.gif height="100%"></TD>
          </TR>
          <%
rs.close
set rs=nothing
%>
          <TR>
            <TD height=10><IMG height=10 src="images/body_03.gif"
            width=601></TD>
          </TR>
        </TBODY>
      </TABLE></TD>
    </TR>
  </TBODY>
</TABLE>
<br>
<!-- #include file="FT.asp" --></BODY></HTML>
2006-08-21 11:59
modigliani
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-8-21
收藏
得分:0 
tj.asp代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file=conn1.asp -->
<HTML><HEAD><TITLE>淄博卫生</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="images/style.css" type=text/css rel=stylesheet>
<STYLE type=text/css>
.main_tab {
    BORDER-RIGHT: gray 0px solid; BORDER-LEFT: #ffffff 0px solid; COLOR: #000000; BORDER-BOTTOM: gray 0px solid; BACKGROUND-COLOR: #d4d0c8
}
body {
    background-image: url(images/bg10.gif);
}
.STYLE3 {
    font-size: 14px;
    font-weight: normal;
}
.style4 {
    font-size: 16px;
    font-family: "黑体";
}
.style5 {
    font-size: x-large;
    font-weight: bold;
}
.style7 {font-size: medium}
</STYLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<script type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</HEAD>
<BODY bgColor=#474747 leftMargin=0 topMargin=0>
 <!-- #include file="TOP.asp" -->
<TABLE cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#ffffff border=0>
  <TBODY>
    <TR>
      <TD vAlign=top align=left colSpan=6 height=4></TD>
    </TR>
    <TR>
      <TD vAlign=top align=left width=72 height=139><SCRIPT language=javascript>
function newWin(url){
    window.open(url,"_blank","");

}
function  search(){
    var sKeyword = keyword.value
    if (sKeyword == ""){
        alert("输入的关键词不能为空!")
        return ;
    }
    var sCategory = category.value;
    var sPath = "../znss/index.asp?keyword="+ sKeyword+"&category="+sCategory;
    var sPath = "../znss/index.asp?keyword="+ sKeyword
    newWin(sPath)

}

document.onkeydown=function(){
   
    if (event.keyCode!=13) return
   
    if (event.srcElement.name=="textfield"){
        search();
    }
    else{
        event.keyCode=9
    }
}
</SCRIPT>
      </TD>
      
      <TD vAlign=top align="left" width=657 height=139><div align="center" class="style5">
        <p> </p>
        <p align="center" class="style7">您的信息已经提交,感谢您对淄博市卫生工作的关心</p>
      </div></TD>
    </TR>
  </TBODY>
</TABLE>
<br>
<!-- #include file="FT.asp" --></BODY></HTML>


2006-08-21 12:00
modigliani
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-8-21
收藏
得分:0 
麻烦您了.... 能够把提交的内容添加到数据库里边就可以..

[此贴子已经被作者于2006-8-21 12:00:57编辑过]


2006-08-21 12:00
hangxj
Rank: 6Rank: 6
等 级:贵宾
威 望:29
帖 子:2045
专家分:0
注 册:2006-4-10
收藏
得分:0 
不好意思,我只能帮你到这,因为我在上面已经给了你代码了,其他要看你自己的了

http://www./
2006-08-21 12:06
modigliani
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-8-21
收藏
得分:0 
哦了...
2006-08-21 12:20
小猪哼哼
Rank: 1
等 级:新手上路
帖 子:68
专家分:0
注 册:2006-8-15
收藏
得分:0 

中午研究了一下,找到问题所在了,如下:

conn.asp
<%
set conn=server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath("data.mdb")
conn.open connstr
%>

jzxx.asp
<%IF Request.QueryString("actionstr")="add" Then%>
<!--#include file=conn1.asp -->
<%
dim Name,Unit,Address,Phone,Fax,Email,Others,Message
set rs=server.createobject("adodb.recordset")
sqltext="select * from Message"
rs.open sqltext,conn,1,3
'添加一个留言到数据库
rs.addnew
rs("Name")=request.form("Name")
rs("Unit")=request.form("Unit")
rs("Address")=request.form("Address")
rs("Phone")=request.form("Phone")
rs("Fax")=request.form("Fax")
rs("Email")=request.form("Email")
rs("Others")=request.form("Others")
rs("Message")=request.form("Message")
rs.update
rs.close
set rs=nothing
conn.close
set conn=nothing
response.Write("<center><meta http-equiv='refresh' content='3;URL=jzxx.asp'><BR><BR><a href='jzxx.asp'>添加成功点击返回或三秒

后自动返回</a></center>")
response.end
else
%>

<HTML><HEAD><TITLE>淄博卫生</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/style.css" type=text/css rel=stylesheet>
<STYLE type=text/css>
.main_tab {
BORDER-RIGHT: gray 0px solid; BORDER-LEFT: #ffffff 0px solid; COLOR: #000000; BORDER-BOTTOM: gray 0px solid;

BACKGROUND-COLOR: #d4d0c8
}
body {
background-image: url(images/bg10.gif);
}
.STYLE3 {
font-size: 14px;
font-weight: normal;
}
.style4 {
font-size: 16px;
font-family: "黑体";
}
.style5 {color: #FF0000}
.style7 {font-size: 16px}
.style8 {font-weight: bold; font-family: "黑体";}
.style10 {font-size: 14}
</STYLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<script type="text/JavaScript">
<!--

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</HEAD>
<BODY bgColor=#474747 leftMargin=0 topMargin=0>
<!-- #include file="TOP.asp" -->
<TABLE cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#ffffff border=0>
<TBODY>
<TR>
<TD vAlign=top align=left colSpan=6 height=4></TD>
</TR>
<TR>
<TD vAlign=top align=left width=72 height=100><SCRIPT language=javascript>
function newWin(url){
window.open(url,"_blank","");

}
function search(){
var sKeyword = keyword.value
if (sKeyword == ""){
alert("输入的关键词不能为空!")
return ;
}
var sCategory = category.value;
var sPath = "../znss/index.asp?keyword="+ sKeyword+"&category="+sCategory;
var sPath = "../znss/index.asp?keyword="+ sKeyword
newWin(sPath)

}

document.onkeydown=function(){

if (event.keyCode!=13) return

if (event.srcElement.name=="textfield"){
search();
}
else{
event.keyCode=9
}
}
</SCRIPT>
</TD>
<TD vAlign=top align=left colSpan=3></TD>
<TD vAlign=top align=left width=657 height=100><TABLE height="311%" cellSpacing=0 cellPadding=0 width=601 border=0>
<TBODY>
<TR>
<TD height="13"><p class="style7"><br>
<span class="style8">局长信箱:</span></p>
<p class="STYLE3">   感谢您对淄博市卫生工作的关心,请提出您的意见或建议。
<br>
<br>
   注:(*)为必添项目</p>
<form name="form1" method="post" action="jzxx.asp?actionstr=add"> '这后面的encType=text/plain是不能要滴。
<table width="512" height="314" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="131" align="center" class="STYLE3">
<label>姓名:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Name" type="text" id="Name" size="33">
*</td>
</tr>
<tr>
<td align="center" class="STYLE3">
<label>单位:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Unit" type="text" id="Unit" size="33">
*</td>
</tr>
<tr>
<td align="center" class="STYLE3">
<label>地址:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Address" type="text" id="Address" size="33">
*</td>
</tr>
<tr>
<td align="center" class="STYLE3">
<label>电话:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Phone" type="text" id="Phone" size="33">
</td>
</tr>
<tr>
<td align="center" class="STYLE3">
<label>传真:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Fax" type="text" id="Fax" size="33">
</td>
</tr>
<tr>
<td align="center" class="STYLE3">
<label>电子邮件:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Email" type="text" id="Email" size="33">
*</td>
</tr>
<tr>
<td align="center" class="STYLE3">
<label>其它联系方式:</label>
</td>
<td colspan="2" class="STYLE3">
<input name="Others" type="text" id="Others" size="33">
</td>
</tr>
<tr>
<td height="102" align="center" class="STYLE3">
<label>你的意见:</label>
</td>
<td height="102" colspan="2" class="STYLE3">
<textarea name="Message" cols="37" rows="10" id="Message"></textarea>
</td>
</tr>
<tr>
<td height="18" align="center">&nbsp;</td>
<td width="227" height="18" align="left" class="STYLE3">
<input name="submit2" type="submit" id="queding2" value="确定">
</td>
<td width="154" align="left" class="STYLE3">
<input name="chongzhi" type="reset" id="chongzhi" value="重置">
</td>
</tr>
<tr>
<td height="16" colspan="3" align="center">&nbsp;</td>
</tr>
<tr>
<td height="14" colspan="3" align="center">&nbsp;</td>
</tr>
</table>
</form>
<p class="STYLE3">&nbsp;</p>
<p class="STYLE3">&nbsp;</p></TD>
</TR>
<TR>
<TD vAlign=center align=middle background=images/body_02.gif
height=13>&nbsp;</TD>
</TR>
<TR>
<TD vAlign=top align=middle background=义乌市卫生局.files/body_02.gif
height=4><IMG height=4 src="images/body_line.gif"
width=588></TD>
</TR>
<TR>
<TD background=义乌市卫生局.files/body_02.gif height="100%"></TD>
</TR>
<TR>
<TD height=10><IMG height=10 src="images/body_03.gif" width=601></TD>
</TR>
</TBODY>
</TABLE></TD>
</TR>
</TBODY>
</TABLE>
<br>
<!-- #include file="FT.asp" --></BODY></HTML>
<%end if%>

[此贴子已经被作者于2006-8-21 14:18:48编辑过]


2006-08-21 14:18
modigliani
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-8-21
收藏
得分:0 
可以了,非常感谢小猪哼哼...
太感谢了........
^_^!!!!

[此贴子已经被作者于2006-8-21 16:42:06编辑过]

2006-08-21 16:41
快速回复:[求助]ASP中提交给数据库的记录都为空
数据加载中...
 
   



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

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