请问为什么向数据库插入数据只能插入最后一条数据?以下是代码,所用数据库为mysql
<!--#includefile="conn.asp"--><!--#includefile="md5.asp"--><%adminname=Trim(Request.F...
<!--#include file="conn.asp" -->
<!--#include file="md5.asp"-->
<%
adminname=Trim(Request.Form("adminname"))
userpw=Request.Form("pw")
quanxian=Request.Form("quanxian")
if adminname="" or userpw="" or quanxian="" then
response.Write"<script>alert('资料填写不完整!');history.back();</script>"
response.End()
end if
'set rs=server.CreateObject("ADODB.Recordset")
' set rs1=server.CreateObject("ADODB.Recordset")
sql1="select * from user where User_Name='"&adminname&"'"
rs1.open sql1,conn,1,3
if rs1.eof or rs1.bof then
strsql="select * from user"
rs.open strsql,conn,2,3
rs.addnew
rs("User_Name")=adminname
rs("User_Pwd")=md5(userpw)
rs("User_qx")=quanxian
response.Write(rs("User_Name")+rs("User_Pwd")+rs("User_qx"))
rs.update
rs.close
set rs=nothing
response.Write"<script>alert('添加管理员:"&adminname&"成功!');location.href='admin_gli.asp';</script>"
response.End()
else
response.Write"<script>alert('用户"&adminname&"已存在,请重新输入用户名!');history.back();</script>"
end if
rs1.close
set rs1=nothing
conn.close
set conn=nothing
%>
只有权限rs("User_qx")=quanxian
这一条能插入,并且利用response.Write(rs("User_Name")+rs("User_Pwd")+rs("User_qx"))检查都不为空。现在假设删掉了rs("User_qx")=quanxian这一句话,整个系统的数据库都瘫痪了。
对了还有rs.addnew一个数据库能建立几个recoredset对象? 展开
<!--#include file="md5.asp"-->
<%
adminname=Trim(Request.Form("adminname"))
userpw=Request.Form("pw")
quanxian=Request.Form("quanxian")
if adminname="" or userpw="" or quanxian="" then
response.Write"<script>alert('资料填写不完整!');history.back();</script>"
response.End()
end if
'set rs=server.CreateObject("ADODB.Recordset")
' set rs1=server.CreateObject("ADODB.Recordset")
sql1="select * from user where User_Name='"&adminname&"'"
rs1.open sql1,conn,1,3
if rs1.eof or rs1.bof then
strsql="select * from user"
rs.open strsql,conn,2,3
rs.addnew
rs("User_Name")=adminname
rs("User_Pwd")=md5(userpw)
rs("User_qx")=quanxian
response.Write(rs("User_Name")+rs("User_Pwd")+rs("User_qx"))
rs.update
rs.close
set rs=nothing
response.Write"<script>alert('添加管理员:"&adminname&"成功!');location.href='admin_gli.asp';</script>"
response.End()
else
response.Write"<script>alert('用户"&adminname&"已存在,请重新输入用户名!');history.back();</script>"
end if
rs1.close
set rs1=nothing
conn.close
set conn=nothing
%>
只有权限rs("User_qx")=quanxian
这一条能插入,并且利用response.Write(rs("User_Name")+rs("User_Pwd")+rs("User_qx"))检查都不为空。现在假设删掉了rs("User_qx")=quanxian这一句话,整个系统的数据库都瘫痪了。
对了还有rs.addnew一个数据库能建立几个recoredset对象? 展开
展开全部
<%
adminname=Trim(Request.Form("adminname"))
userpw=Request.Form("pw")
quanxian=Request.Form("quanxian")
if adminname="" or userpw="" or quanxian="" then
response.Write"<script>alert('资料填写不完整!');history.back();</script>"
response.End()
end if
set rs1=server.CreateObject("ADODB.Recordset")
sql1="select * from user where User_Name='"&adminname&"'"
rs1.open sql1,conn,1,3
if rs1.eof or rs1.bof then
set rs=server.CreateObject("ADODB.Recordset")
strsql="select * from user"
rs.open strsql,conn,1,3
rs.addnew
rs("User_Name")=adminname
rs("User_Pwd")=md5(userpw)
rs("User_qx")=quanxian
response.Write adminname&md5(userpw)&quanxian
rs.update
rs.close
set rs=nothing
response.Write"<script>alert('添加管理员:"&adminname&"成功!');location.href='admin_gli.asp';</script>"
else
response.Write"<script>alert('用户"&adminname&"已存在,请重新输入用户名!');history.back();</script>"
end if
rs1.close
set rs1=nothing
conn.close
set conn=nothing
%>
这样试试。。再不然就得检查数据库类型等等。
adminname=Trim(Request.Form("adminname"))
userpw=Request.Form("pw")
quanxian=Request.Form("quanxian")
if adminname="" or userpw="" or quanxian="" then
response.Write"<script>alert('资料填写不完整!');history.back();</script>"
response.End()
end if
set rs1=server.CreateObject("ADODB.Recordset")
sql1="select * from user where User_Name='"&adminname&"'"
rs1.open sql1,conn,1,3
if rs1.eof or rs1.bof then
set rs=server.CreateObject("ADODB.Recordset")
strsql="select * from user"
rs.open strsql,conn,1,3
rs.addnew
rs("User_Name")=adminname
rs("User_Pwd")=md5(userpw)
rs("User_qx")=quanxian
response.Write adminname&md5(userpw)&quanxian
rs.update
rs.close
set rs=nothing
response.Write"<script>alert('添加管理员:"&adminname&"成功!');location.href='admin_gli.asp';</script>"
else
response.Write"<script>alert('用户"&adminname&"已存在,请重新输入用户名!');history.back();</script>"
end if
rs1.close
set rs1=nothing
conn.close
set conn=nothing
%>
这样试试。。再不然就得检查数据库类型等等。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询