郁闷一晚上,代码实现不了,请各位帮我看看!!!!!!!!

shawshanke 2003-03-20 09:56:50
两个页面:login.asp logincheck.asp,前一个是用户登陆,后一个验证登陆!

login.asp:

<%@language="vbscript"%>
<html>
<body>
<form action="logincheck.asp" method="post" enctype="multipart/formdata">
username:<input type=text name=username >
password:<input type=password name=password >
<input type=submit>
<Input type=reset>
</form>
</body>
</html>

<%
dim rs,con,connectionstring,cmd
connectionstring="Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=shopcart;Data Source=shawshanke"
set con=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
con.open connectionstring
rs.activeconnection=con
rs.cursorlocation=aduseclient
set cmd=server.createobject("adodb.connection")

%>


logincheck.asp:

<%@language="vbscript"%>
<%
dim rs,con,connectionstring,cmd
connectionstring="Provider=SQLOLEDB;Integrated Security=SSPI;Initial Catalog=shopcart;Data Source=shawshanke;Persist Security Info=False"
set con=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")
con.open connectionstring
rs.activeconnection=con
rs.cursorlocation=adUseClient
set cmd=server.createobject("adodb.command")
cmd.activeconnection=connectionstring

username=request.form("username")
password=request.form("password")


sql="select orders.order_id, product.product_name, orders.customer_id,customer.last_name,customer.first_name,customer.customer_id,product.product_id,order_item_detail.quantity,order_item_detail.order_item_status"&_
"from orders,product,customer,order_item_detail"&_
"where customer.customer_id=orders.customer_id and order_item_detail.product_id=product.product_id and orders.order_id=order_item_detail.order_id and"&_
"upper(ltrim(rtrim(customer.user_name)))=" & ucase(username) &_
"and upper(ltrim(rtrim(customer.password)))=" &_
"ucase(password)"
rs.open sql,con,1,1

if not (rs.bof or rs.eof) then
customerid=rs("customer_id")
response.cookies("cartid"=rs("order_id"))
response.cookies("customerid"=rs("customer_id"))
response.cookies("customerid".expires="december 31,2005")
response.write "<b>hello"&rs("first_name")&" "&rs("last_name")&_
"</b><br>"
response.write "here are some details about your previous order/s you"&_
"might be interested in <br><br>"

do while not rs.eof
response.write "product_name:"&" "&rs("product_name")&"<br>"
response.write "quantity:"&" "&rs("quantity")&"<br>"
response.write "status:"&" "&rs("order_item_status")&"<br>"
rs.movenext
loop
rs.close

else
sql="select customer_id from customer where"&_
"upper (ltrim(rtrim(customer.user_name)))="&"'"&ucase(username)&"'"&_
"and upper(ltrim(rtrim(customer.password)))="&"'"&ucase(password)&"'"

rs.open sql,con,adopendynamic

if not (rs.bof or rs.eof) then
customerid=rs("customer_id")
reponse.cookies("customerid")=customerid
reponse.cookies("customerid").expires="december 31,2005"

response.redirect"storefront.asp"

else
response.write"<h2>we could not find your records please"&_
"re-register or contact your sales represetative</h2><br>"
response.write"<h4>or go to the store front to continue shopping"&_
"</h4><br>"
end if
end if

response.write "<hr>"
response.write "<a href=products.asp>continue shopping</a>"
response.write "   "
response.write "<a href=storefront.asp>store front</a>"

%>

有错误:说logincheck.asp的rs.open sql,con,1,1的'.'附近有错误!
麻烦帮忙调试调试!
...全文
668 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Andyken 2003-03-21
  • 打赏
  • 举报
回复
在logincheck.asp文件开头
<%@language="vbscript"%>
<%
if isObject(rs)=true then
set rs=nothing
end if
if isObject(con)=true then
set con=nothing
end if
''''''''''your other code

%>
然后rs.open sql,con,1,3--------->试试看
要是还有问题就是你的sql语句写错了
要不你把sql语句response.write 出来
copy到到数据库的查询分析器里运行。看看结果。
funboy88 2003-03-21
  • 打赏
  • 举报
回复
连接的地方帐号密码都没有,你怎么能连上数据库的呀
cryingboy 2003-03-21
  • 打赏
  • 举报
回复
楼上可能说对了,在数据库连接之后,做个简单的查询看一下,能成功不!
daanhan 2003-03-21
  • 打赏
  • 举报
回复
少了空格吧,比如下面的样子

……order_item_detail"&_
"where cust……

应该改成

……order_item_detail "&_
"where cust……
ChaoHan 2003-03-21
  • 打赏
  • 举报
回复
rs.open sql,con,1,1出问题时,请检查数据库连接和SQL语句是否都正确,逐一的排除问题。同时将打开的表关掉。
tenflee 2003-03-21
  • 打赏
  • 举报
回复
<form action="logincheck.asp" method="post" enctype="multipart/formdata">

这一行有错了,enctype="multipart/formdata"一般是用来传输二进制数据的,用户登录不需要这些,把它去掉

其它地方我没有发现有错 :)
coffee_black 2003-03-21
  • 打赏
  • 举报
回复
呵呵
dh20156 2003-03-21
  • 打赏
  • 举报
回复
UP ^_^
eafin 2003-03-21
  • 打赏
  • 举报
回复
<form action="logincheck.asp" method="post" enctype="multipart/formdata">
你的传输形式是使用二进制??
<form action="logincheck.asp" method="post">
zhongallen 2003-03-20
  • 打赏
  • 举报
回复
你的连接字符串中似乎缺少了User ID=?;Password=?这个吧,否则如何成功连接数据库啊?
shawshanke 2003-03-20
  • 打赏
  • 举报
回复
试了,还是一样的错误!
jiangjian0427 2003-03-20
  • 打赏
  • 举报
回复
if not (rs.bof or rs.eof) then 改为:
if not rs.eof or rs.bof then

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧