我是初学者,这段代码原运行都没事,可是后来添加了connection的事务后,就出错了,看了好几遍也不知道错在哪,请高手指一二,先行谢过。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- #include file = "db.inc.asp" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<center>
<table width="400" height="691" border="0">
<tr>
<td align="center" valign="middle">
<%
set rst = Server.CreateObject("adodb.recordset")
rst.open "select * from user where u_user ='"&request.form("f_id")&"'", conn, 1, 1
if rst.recordcount>0 then
response.write("用户名已经存在,请重新填写")
rst.close
set rst = nothing
conn.close
set conn = nothing
response.end
else
conn.begintrans
rst.close
rst.open "user", conn, 1, 3
rst.addnew
rst("u_user") = request.form("f_id")
rst("u_code") = request.form("f_pas")
rst.update
rst.close
set rst1 = conn.Execute("select @@IDENTITY as uid")
uid = rst1("uid")
rst.open "info", conn, 1, 3
rst.addnew
rst("i_uid") = uid
rst("i_name") = request.form("f_name")
rst("i_sex") = request.form("f_sex")
rst("i_age") = request.form("f_age")
rst("i_vip") = false
rst.update
rst.close
if err.number<>0 then
conn.rollbacktrans
%>
<img src="img/zcsb.jpg" width="357" height="229" /><br />
<%
else
conn.committrans
%>
<img src="img/zccg.jpg" width="355" height="240" />
<%
end if
end if
%>
</td>
</tr>
</table>
<%
set rst = nothing
conn.close
set conn = nothing
%>
</center>
</body>
</html>