主题:为什么无法实现
我使用的数据库是:SQL Server 2000
建立的数据源是:系统数据源:health,使用了Windows身份认证,默认数据库为“食物营养”
在“食物营养”数据库中,有一张表“用户权限表”,记录了用户名和密码
我想通过ASP访问这张表,判断用户输入的用户名和密码是不是正确,可实现不了。
请大家帮我看看,下面的代码哪里有问题:
---------------------------------------------------------------------------
load.htm
---------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登入</title>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<form name="dl" method="get" action="rz.asp">
<p align="center"> 用户名:
<input name="user" type="text" maxlength="16">
</p>
<p align="center">密 码:
<input name="word" type="password" maxlength="16">
</p>
<p align="center">
<input name="clear" type="reset" id="clear" value="重置">
<input name="submit" type="submit" id="submit" value="提交">
</p>
</form>
</body>
</html>
---------------------------------------------------------------------------
rz.asp
---------------------------------------------------------------------------
<%@ language=VBScript%>
<html>
<head>
</head>
<body>
<%
Set conn = Server.CreateObject("adodb.connection")
User=Request.QueryString("user")
Password=Request.QueryString("word")
conn.open "DSN=health;UID=;PWD=;DATABASE=食物营养"
sql="SELECT 用户名,密码 FROM 用户权限表 WHERE 用户名=' " &User& " ' and 密码=' " &Password& " ' "
Set rs=conn.Execute(sql)
%>
<% If rs.EOF Then%>
<script language="VBScript">
alert "用户名或密码有误,请重新输入!"
</script>
<% Else %>
<script language="VBScript">
alert "用户名或密码正确!"
</script>
<%
End If
conn.close
Set conn=nothing
%>
</body>
</html>
建立的数据源是:系统数据源:health,使用了Windows身份认证,默认数据库为“食物营养”
在“食物营养”数据库中,有一张表“用户权限表”,记录了用户名和密码
我想通过ASP访问这张表,判断用户输入的用户名和密码是不是正确,可实现不了。
请大家帮我看看,下面的代码哪里有问题:
---------------------------------------------------------------------------
load.htm
---------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>登入</title>
</head>
<body bgcolor="#000000" text="#FFFFFF">
<form name="dl" method="get" action="rz.asp">
<p align="center"> 用户名:
<input name="user" type="text" maxlength="16">
</p>
<p align="center">密 码:
<input name="word" type="password" maxlength="16">
</p>
<p align="center">
<input name="clear" type="reset" id="clear" value="重置">
<input name="submit" type="submit" id="submit" value="提交">
</p>
</form>
</body>
</html>
---------------------------------------------------------------------------
rz.asp
---------------------------------------------------------------------------
<%@ language=VBScript%>
<html>
<head>
</head>
<body>
<%
Set conn = Server.CreateObject("adodb.connection")
User=Request.QueryString("user")
Password=Request.QueryString("word")
conn.open "DSN=health;UID=;PWD=;DATABASE=食物营养"
sql="SELECT 用户名,密码 FROM 用户权限表 WHERE 用户名=' " &User& " ' and 密码=' " &Password& " ' "
Set rs=conn.Execute(sql)
%>
<% If rs.EOF Then%>
<script language="VBScript">
alert "用户名或密码有误,请重新输入!"
</script>
<% Else %>
<script language="VBScript">
alert "用户名或密码正确!"
</script>
<%
End If
conn.close
Set conn=nothing
%>
</body>
</html>