首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

asp小疑点,多谢了

2012-03-12 
asp小问题,谢谢了htmlhead/headbody%DB123.mdb数据库路径和文件名,请修改引号中的文件名这

asp小问题,谢谢了
<html>
<head></head>
<body>
<%
DB="123.mdb"'数据库路径和文件名,请修改引号中的文件名
'这一句很关键,不能删除
set conn=server.createobject("adodb.Connection")
connstr="provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB)
conn.Open connstr
%>



name=trim(request.Form("adminusername"))
pass=trim(request.Form("password"))

<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where u_name='"&name&"' and u_pass='"&pass&"'"
rs.open sql,conn,1,1
if not rs.eof then
username=rs("u_name")
session("lifeuser")=username
session.Timeout=10

response.Redirect"3.asp"
else
response.redirect"4.asp"
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
%>


数据表admin中有两项u_user u_pass 分别为123 123
无论输入什么,结果都为false
求解,谢谢了

[解决办法]
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where u_name='"&name&"' and u_pass='"&pass&"'"
rs.open sql,conn,1,1
if not rs.eof then
username=rs("u_name")
session("lifeuser")=username
session.Timeout=10

response.Redirect"3.asp"
else
response.redirect"4.asp"
end ifrs.close
set rs=nothing
conn.close
set conn=nothing



[解决办法]
set rs=server.CreateObject("adodb.recordset")
sql="select * from admin where u_name='"&name&"' and u_pass='"&pass&"'"
rs.open sql,conn,1,1
if not rs.eof then
username=rs("u_name")
session("lifeuser")=username
session.Timeout=10

response.Redirect"3.asp"
else
response.redirect"4.asp"
end if

rs.close
set rs=nothing
conn.close
set conn=nothing

[解决办法]
当然有问题啊

name=trim(request.Form("adminusername"))
pass=trim(request.Form("password"))


这两句话要放到<%%>中去,你直接放到外面,系统以纯文本处理,name和pass永远为空
[解决办法]

VBScript code
<%'你把代码格式写好点啊,看得烦Dim DB, conn, rs, connstr, name, pass, sql usernameDB = "123.mdb" '数据库路径和文件名,请修改引号中的文件名Set conn = Server.CreateObject("Adodb.Connection")connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(DB)conn.Open connstrname = Trim(Request.Form("adminusername"))pass = Trim(Request.Form("password"))Set rs = Server.CreateObject("Adodb.RecordSet")sql = "select * from admin where u_name='" & name & "' and u_pass='" & pass & "'"rs.Open sql,conn,1,3If Not rs.EOF Then    username = rs("u_name")    Session("lifeuser") = username    Session.Timeout = 10    Response.Redirect "3.asp"Else    Response.Redirect "4.asp"End Ifrs.closeconn.CloseSet rs = NothingSet conn = nothing%> 

热点排行