关于ASP操作数据库的问题!!!
我想让管理员用户可以输入用户名来实现修改和删除用户!~大家帮帮忙!~conn.asp文件代码<%setconn=server.CreateObject("adodb.co...
我想让管理员用户可以输入用户名来实现修改和删除用户!~大家帮帮忙!~
conn.asp文件代码
<%
set conn=server.CreateObject("adodb.connection")
conn.open"DRIVER=Driver do Microsoft Access (*.mdb);dbq="&server.MapPath("abcd.mdb")
%>
pan1.asp这个是判定页面
<!--#include file="conn.asp"-->
<%
dim a,b
a=request.Form("f_user")
b=request.Form("f_pass")
set rs4=conn.Execute("select * from user2 where i_user='"&a&"'and i_pass='"&b&"'")
if rs4.eof then
response.Write("账号或密码错误!")
else
set rs2=conn.Execute("select * from user ")
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>账号</td>"
response.Write"<td>密码</td>"
response.Write"</tr>"
response.Write"</table>"
if rs2.eof then
response.Write"数据库为空!"
else
do while not rs2.eof
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>"&rs2=("u_user")&"</td>"
response.Write"<td>"&rs2=("u_pass")&"</td>"
rs2.movenext
response.Write"</tr>"
loop
end if
response.Write"</table>"
end if
%> 展开
conn.asp文件代码
<%
set conn=server.CreateObject("adodb.connection")
conn.open"DRIVER=Driver do Microsoft Access (*.mdb);dbq="&server.MapPath("abcd.mdb")
%>
pan1.asp这个是判定页面
<!--#include file="conn.asp"-->
<%
dim a,b
a=request.Form("f_user")
b=request.Form("f_pass")
set rs4=conn.Execute("select * from user2 where i_user='"&a&"'and i_pass='"&b&"'")
if rs4.eof then
response.Write("账号或密码错误!")
else
set rs2=conn.Execute("select * from user ")
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>账号</td>"
response.Write"<td>密码</td>"
response.Write"</tr>"
response.Write"</table>"
if rs2.eof then
response.Write"数据库为空!"
else
do while not rs2.eof
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>"&rs2=("u_user")&"</td>"
response.Write"<td>"&rs2=("u_pass")&"</td>"
rs2.movenext
response.Write"</tr>"
loop
end if
response.Write"</table>"
end if
%> 展开
展开全部
不好意思,写错了,跟进如下:
insert
into
test
(num,test)
(select
isnull(max(num),0)+1,'test'
from
test)
这个语法有点特殊,稍稍解释一下:
因为你要先检索出最大值再插入,而
values不支持检索,所以这里必须去掉values关正扒键字
你可以这样来理解:
要插入的字段值num,test是从另一个嫌闹表里取出来的字段值
如果有更多字段,那么可以这样写:
insert
into
test
(num,test1,test2,test3)
(select
isnull(max(num),0)+1,'test1','test2','test3'
from
test)
补充:
可能ACCESS里不支芹清罩持isnull,你可以去掉它啊,不过前提是你数据库里至少要有一条记录,因为如果max(num)取不到值,会报错的。
insert
into
test
(num,test)
(select
max(num)+1,'test'
from
test)
insert
into
test
(num,test)
(select
isnull(max(num),0)+1,'test'
from
test)
这个语法有点特殊,稍稍解释一下:
因为你要先检索出最大值再插入,而
values不支持检索,所以这里必须去掉values关正扒键字
你可以这样来理解:
要插入的字段值num,test是从另一个嫌闹表里取出来的字段值
如果有更多字段,那么可以这样写:
insert
into
test
(num,test1,test2,test3)
(select
isnull(max(num),0)+1,'test1','test2','test3'
from
test)
补充:
可能ACCESS里不支芹清罩持isnull,你可以去掉它啊,不过前提是你数据库里至少要有一条记录,因为如果max(num)取不到值,会报错的。
insert
into
test
(num,test)
(select
max(num)+1,'test'
from
test)
展开全部
user 是关键词,用作表名芹野或字段名是要用[ ]括起来。
pan1.asp 可改为
<!--#include file="conn.asp"-->
<%
dim a,b
a=request.Form("f_user")
b=request.Form("f_pass")
set rs4=conn.Execute("select * from user2 where i_user='"&a&"'and i_pass='"&b&"'")
if rs4.eof then
response.Write("账号或密码错误!")
else
set rs2=conn.Execute("select * from [user] ") '修改这一行
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>账号</td>"
response.Write"<td>密码</td>"
response.Write"</tr>"
response.Write"</table>"腔首春
if rs2.eof then
response.Write"数据库为空!"
else
do while not rs2.eof
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>"&rs2=("u_user")&"</td>"
response.Write"<td>"&rs2=("u_pass")&"</td>"
rs2.movenext
response.Write"伍耐</tr>"
loop
end if
response.Write"</table>"
end if
%>
pan1.asp 可改为
<!--#include file="conn.asp"-->
<%
dim a,b
a=request.Form("f_user")
b=request.Form("f_pass")
set rs4=conn.Execute("select * from user2 where i_user='"&a&"'and i_pass='"&b&"'")
if rs4.eof then
response.Write("账号或密码错误!")
else
set rs2=conn.Execute("select * from [user] ") '修改这一行
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>账号</td>"
response.Write"<td>密码</td>"
response.Write"</tr>"
response.Write"</table>"腔首春
if rs2.eof then
response.Write"数据库为空!"
else
do while not rs2.eof
response.Write"<table width=200 border=1>"
response.Write"<tr>"
response.Write"<td>"&rs2=("u_user")&"</td>"
response.Write"<td>"&rs2=("u_pass")&"</td>"
rs2.movenext
response.Write"伍耐</tr>"
loop
end if
response.Write"</table>"
end if
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询