<!-- #include file="db.inc.asp" -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册结果</title>
<style type="text/css">
<!-
body {
margin-top: 0px;
margin-bottom: 0px;
background-image: url();
background-repeat: no-repeat;
}
.STYLE2 {
font-size: 50px;
font-weight: bold;
color: #FF0000;
}
-->
</style></head>
<body>
<% on error resume next '如果发生了错误,就跳过发生错误的代码,继续向下运行%>
<table width="800" border="0" align="center" cellspacing="0">
<tr>
<td width="218" height="72"> </td>
<td width="376"> </td>
<td width="200"> </td>
</tr>
<tr>
<td> </td>
<td align="center" valign="middle">
<%
'创建recordset对象方法1
set rst=server.CreateObject("adodb.recordset")
rst.open "select * from user where u_user='" & request.form("f_user") & "'",conn,1,1
if rst.recordcount>0 then
'如果存在这个用户名,对用户进行提示
response.write "用户名:" & request.form("f_user") & "已经被占用!请点击后退按钮返回上一页!"
rst.close
set rst=nothing
conn.close
set rst=nothing
response.End()
else
'如果用户名不存在则写入数据
set rst1=conn.Execute("insert into user (u_user,u_code) values ('" & request.Form("f_user") & "','" & request.form("f_code") & "')")
rst.close
rst.open "user",conn,1,3
rst.addnew'插入数据到user表
rst("u_user")=request.form("f_user")
rst("u_code")=request.Form("f_code")
rst.update
rst.close
'获取刚才插入数据的自动编号字段值,即u_id字段的值
set rst1=conn.execute("select @@identity as uid")
uid=rst1("uid")
rst.open "info",conn,1,3
set myerrors=conn.errors
if myerrors.count>0 then
for i=0 to myerrors.count-1
response.Write("错误原因:" & myerrors.item(i).description & "<br>")
next
end if
if err.number<>0 then
response.Write "ERR对象捕获错误:" & err.description
end if
rst.addnew'插入数据到info表
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
%>
<span class="STYLE2">注册失败</span><br>
<% else %>
<span class="STYLE2">注册成功</span></td>
<%
end if
end if
%>
<td> </td>
</tr>
<tr>
<td height="154"> </td>
<td> </td>
<td> </td>
</tr>
</table>
<%
set rst=nothing
conn.close
set conn=nothing
%>
</body>
</html>47/48 shandian
rst.open "select * from user where u_user='" & request.form("f_user") & "'",conn,
#注 user是数据库表名,u_user是表里的某个字段名,request.form("f_user")里的f_user是你页面里的<form></form>里的某个表单名,比如:<input name=f_user type=text>