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

这段代码错在哪里?

marrylily 发布于 2008-06-16 17:41, 391 次点击
<%
dim rst,sql
if request.querystring("act")="cf" then
set rst=server.createobject("adodb.recordset")
sql="tbl_affiche"
   rst.open sql,conn,1,3
   conn.begintrans
   rst.addnew
   rst("a_title")=request.form("f_title")
   rst("a_content")=request.form("f_content")
   rst.update
   if err.number<>0 then
   conn.rollbacktrans
   response.write "公告发布失败!错误原因:"&err.description
   else
   
   response.write "公告发布成功!"
   end if
else
end if
%>

<form method="post" action="admin_affiche.asp?act=cf">
<table width="600" height="214" border="0" cellpadding="0" cellspacing="0">
  <tr align="left">
    <td height="40" colspan="2">公告系统</td>
  </tr>
  <tr>
    <td width="161" height="40" align="right">公告标题:</td>
    <td width="439"><input name="f_title" type="text" class="box"></td>
  </tr>
  <tr valign="top">
    <td align="right">公告内容:</td>
    <td><textarea name="f_content" cols="66" rows="12" wrap="OFF"></textarea></td>
  </tr>
  <tr align="center">
    <td height="40" colspan="2"><input type="submit" name="sub" value="提交公告">&nbsp;&nbsp;&nbsp;<input type="reset" value="清除"></td>
  </tr>
</table>
</form>
<%
rst.close
set rst=nothing
conn.close
set conn=nothing
%>
为什么不能写入数据库?
4 回复
#2
marrylily2008-06-16 19:48
回帖是一种美德,!欢迎发表自己的见解
#3
madpbpl2008-06-17 03:01
sql="tbl_affiche"
tbl_affiche在哪定义了?
#4
marrylily2008-06-17 10:07
有引用文件的啊
<!-- #include file="../config/db.asp" -->
<!-- #include file="../config/function.inc.asp" -->
#5
hmhz2008-06-17 10:12
conn.begintrans 放到文件顶部
1