ASP添加记录出错!
程序代码:
<!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="提交" /> <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 %>