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

ASP添加记录出错!

执着的小窝 发布于 2012-03-24 11:27, 448 次点击
程序代码:
<!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>Persistent's Diary</title>
<link rel="stylesheet" type="text/css" href="style/css.css" />
<style type="text/css">
<!--
.STYLE6
{font-size: 10}
.STYLE7
{font-size: 16px}
-->
</style>
</head>
<body>
<!--#include file="header.asp"-->


<div id=writebook">
    <h1><span class="STYLE6"><a href="book.asp"><span class="STYLE7">查看留言』</span></a><span class="STYLE7">-<a href="write.asp">『发表留言』 </a></span></span> </h1>
   
<br>
<br>
  <div >
<form name="form1" method="post" action="lysave.asp">
<table width="551" height="268" align="center">
  <tr>
    <td width="59" height="26">标题:</td>
    <td width="363"><input name="lybt" type="text" id="lybt" size="30" /></td>
    </tr>
  <tr>
    <td height="32">姓名:</td>
    <td><input name="lyxm" type="text" id="lyxm" size="30" /></td>
  </tr>
  <tr>
    <td>内容:</td>
    <td><textarea name="lynr" id="lynr" cols="65" rows="12"></textarea></td>
    </tr>
  <tr>
    <td height="37" colspan="2"><div align="center">
      <input type="submit" name="button" id="button" value="提交"  />
      &nbsp;
      <input type="reset" name="button2" id="button2" value="重置" />
    </div></td>
    </tr>
</table>

</form>
  </div>
</div>

<!--#include file="footer.asp"-->   
</body>
</html><%
dim lybt,lyxm,lynr,conn,connstr,sql,rsly

   lybt
=request.form("lybt")
   lyxm
=request.form("lyxm")
   lynr
=request.form("lynr")

  
if lybt="" or lyxm="" or lynr="" then
  response.write(
"<script>alert('填写错误!');  window.location.href='write.asp'")
else
   
set conn=server.createobject("adodb.connection")
   connstr
="provider.microsoft.oledb.jet.4.0;data source=" &server.mappath("2012.mdb")
   conn.open connstr
   
set rsly = server.createobject("adodb.recordset")
   sql
="select * from guestbook "
   rsly.open sql,conn,
1,3
   rsly.addnew
   rsly(
"lybt")= lybt
   rsly(
"lyxm")= lyxm
   rsly(
"lynr")= lynr
   rsly.update
   response.end
   
end if
   rsly.close
   
set rsly= nothing
   conn.close
   
set conn =nothing
   


%>



4 回复
#2
jonathen2012-03-24 11:33
报啥子错误?你要说那个地方出错了呀、!
#3
执着的小窝2012-03-24 11:47
回复 2楼 jonathen
就是不能跳转.添加记录加不进去!
#4
joyceccc2012-03-25 10:16
程序分段执行一下,看看数据库打开了吗?加个Response.write()试试。
#5
jonathen2012-03-26 09:13
response.write("<script>alert('填写错误!');  window.location.href='write.asp'")
这个地方报错,封号应该用英文输入时候的;,另外 第一个 你先看下数据库打开了没有 第二个 你测试一下看看数据传过来了没有!
1