| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 774 人关注过本帖
标题:ASP+ACCESS 插入数据时出错
只看楼主 加入收藏
魏兴耀
Rank: 8Rank: 8
来 自:江西
等 级:蝙蝠侠
威 望:3
帖 子:246
专家分:840
注 册:2009-11-9
结帖率:94.12%
收藏
已结贴  问题点数:10 回复次数:3 
ASP+ACCESS 插入数据时出错
ASP+ACCESS 插入数据时出错,我做的是一个表单插入数据到数据库里去的,
输入完数据后提交后出错,它提示说:

Microsoft JET Database Engine '80040e14'

INSERT INTO 语句的语法错误。

\add.asp, line 97


现在将代码贴在下面

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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>
<style type="text/css">
<!--
body {
    background-color: #FFFFCC;
}
-->
</style></head>

<body >
<form name="formadd" method="post" action="">
<table width="499" border="0" cellpadding="0" cellspacing="0"align="center">
  <!--DWLayoutTable-->
  <tr>
    <td height="37" colspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
      <!--DWLayoutTable-->
      <tr>
        <td width="499" height="37"  align="center"><font size="+3">新增记录</font></td><p><p><p>
      </tr>
    </table>    </td>
 </tr>
  <tr >
    <td width="97" height="22" align="center"> 姓名<!--strName--></td>
    <td width="402" align="left" ><label>
      <input name="textName" type="text">
    </label></td>
  </tr>
  <tr >
    <td height="21" align="center">性别</td>
    <td align="left"><!--strAge-->
      <label>
      <input name="rad" type="radio" value="男">
      男&nbsp;&nbsp;
      <input type="radio" name="rad" value="女">
      女</label></td>
  </tr>
  <tr>
    <td height="23" align="center">年龄</td>
    <td align="left" valign="top" ><label>
      <input name="textAge" type="text">
    </label></td>
  </tr>
  <tr>
    <td height="26" align="center">&nbsp;电话<!--strTell--></td>
    <td valign="top" ><label>
      <input name="textTell" type="text">
    </label></td>
  </tr>
  <tr>
    <td height="25" align="center">&nbsp;邮箱<!--strEmail-->&nbsp;</td>
    <td align="left"><label>
      <input name="textEmail" type="text">
    </label></td>
  </tr>
  <tr>
    <td height="61" align="center">个人简介</td>
    <td align="center"><label>
      <textarea name="textinf" cols="55" rows="5"></textarea>
    </label></td>
  </tr>
  <tr>
    <td height="38" align="center" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
    <td align="center"><label>
      <input type="submit" name="Submit" value="确定">
    </label></td>
  </tr>
  <tr>
    <td height="0"></td>
    <td></td>
  </tr>
</table>
</form>
<% if request.Form("textName")<>"" and request.Form("textTell")<>"" then
      dim strName,strSex,intAge,strTell,strEmail,strInf
          strName=request.Form("textName")
          strSex=request.Form("rad")
       if request.Form("textAge")<>"" then
          intAge=request.Form("textAge")
       else
          intAge=0
       end if
          strTell=request.Form("textTell")
          strEmail=request.Form("textEmail")
          strInf=request.Form("textinf")
'连接数据库
Set conn = Server.CreateObject("ADODB.Connection")
strConn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Server.MapPath("db/address.mdb")
conn.Open strConn
'下面添加数据
         dim sql
         sql="Insert Into tbUsers(strName,strSex,strAge,strTell,strEmail,strInf,dtmSubmit) value                       ('" & strName & "','" & strSex & "'," & intAge & ",'" & strTell & "','" & strEmail & "','" & strInf & "',#" & date() & "#)"
    conn.execute(sql)       (这就是第97行)
         '添加记录以后返回首页
         response.redirect "index.asp"
end if
%>

</body>
</html>




搜索更多相关主题的帖子: ACCESS ASP 数据 
2010-05-12 14:43
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
收藏
得分:5 
sql="Insert Into tbUsers(strName,strSex,strAge,strTell,strEmail,strInf,dtmSubmit) values                       ('" & strName & "','" & strSex & "'," & intAge & ",'" & strTell & "','" & strEmail & "','" & strInf & "',#" & date() & "#)"
注意看红色字体!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-05-12 15:24
craft001wen
Rank: 2
等 级:论坛游民
帖 子:242
专家分:62
注 册:2006-5-4
收藏
得分:5 
value改为values 且后面不要有空格

2010-05-12 16:07
魏兴耀
Rank: 8Rank: 8
来 自:江西
等 级:蝙蝠侠
威 望:3
帖 子:246
专家分:840
注 册:2009-11-9
收藏
得分:0 
谢谢大家啊,我传上来以后就发现错误了,就是那个VALUE的错,不过还是谢谢啊

只有大胆尝试,才有机会得到想要的成功
2010-05-12 21:53
快速回复:ASP+ACCESS 插入数据时出错
数据加载中...
 
   



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

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