使用 Asp.Net 向数据库插入数据的方式
发布时间:2023-07-27 14:12:43 所属栏目:Asp教程 来源:
导读:asp中用insert into语句向数据库插入记录信息的方法,学习的朋友可以参考下。
一、'建立register.asp
<%@ language=vbscript %>
<html >
<head>
<title>注册页面</title>
<meta http-eq
一、'建立register.asp
<%@ language=vbscript %>
<html >
<head>
<title>注册页面</title>
<meta http-eq
asp中用insert into语句向数据库插入记录信息的方法,学习的朋友可以参考下。 一、'建立register.asp <%@ language=vbscript %> <html > <head> <title>注册页面</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <style type="text/css"> td img {display: block;}.STYLE2 {font-size: 12px} .STYLE3 { color: #FF0000; font-weight: bold; font-size: 16px; } </style> </head> <body bgcolor="#ffffff"> <table width="531" border="0" align="center" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <!-- fwtable fwsrc="未命名" fwbase="register.jpg" fwstyle="Dreamweaver" fwdocid = "1502317357" fwnested="0" --> <tr> <td width="58" rowspan="5" valign="top" bgcolor="#D8FBB5"><img src="spacer.gif" width="58" height="1" border="0" border="0" src="/uploads/allimg/130108/132S634L-0.jpg" /> asp中用insert into语句向数据库插入记录的方法 这时打开数据表user会看到: asp中用insert into语句向数据库插入记录的方法 说明操作成功,因为已经提交两次,所以我们看到表中插入了两条新的记录,但是表中出现了重复记录,以下在result2.asp中添加代码予以解决: <%@ language=vbscript %> <!-- #include file="con1.asp"--> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>注册成功</title> <style type="text/css"> <!-- .STYLE1 {font-size: 24px} --> </style> <br></head><body> <% '建立recordset对象方法 set rst=server.createobject("adodb.recordset") rst.open"select * from user where u_user='"&request.form("u_user") & "'",conn,1,1 if rst.recordcount>0 then response.write"用户名:"&request.form("u_user")&"已被占用,请点击返回重新注册" %> <a href="register.asp" class="STYLE1">返回重新注册</a> <% response.End else set rst1=conn.execute("insert into user (u_user,u_pass) values('"&request.form("u_user")&"','"&request.form("u_pass")&"')") end if %> <table width="300" border="0" align="center"> <tr> <td align="center"><img src="chenggong.jpg" alt="注册成功" width="297" height="201"></td> </tr> <tr> <td align="center"><a href="register.asp" class="STYLE1">返回</a></td> </tr> </table> </body> </html> (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐