| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 355 人关注过本帖
标题:[求助]在线购书ASP程序,解释下程序
只看楼主 加入收藏
wqf11111
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-10-29
收藏
 问题点数:0 回复次数:0 
[求助]在线购书ASP程序,解释下程序

<%@ LANGUAGE="VBScript" %>
<html>
<head>
<script language="vbscript">
<!--
' 注释:定义放入购物袋的操作过程
Sub DoOrder(infstr)
' 注释:获取图书订购数量
ordernum = Prompt("请输入您的订购数量!", "1")
' 注释:验证订购数量信息
If Not IsNull(ordernum) Then
If IsNumeric(ordernum) Then
' 注释:将购书信息以字符串的形式保存在文件sale5.asp隐藏表单控件中
bookinf = Split(infstr, ";")
If parent.sale5.fbag.ISBNs.value = "" Then
parent.sale5.fbag.ISBNs.value = bookinf(0)
parent.sale5.fbag.titles.value = bookinf(1)
parent.sale5.fbag.nums.value = ordernum
Else
parent.sale5.fbag.ISBNs.value = parent.sale5.fbag.ISBNs.value & ";" & bookinf(0)
parent.sale5.fbag.titles.value = parent.sale5.fbag.titles.value & ";" & bookinf(1)
parent.sale5.fbag.nums.value = parent.sale5.fbag.nums.value & ";" & ordernum
End If
' 注释:更新购物袋的显示
parent.sale5.fbag.submit
Else
Alert("订购数量只能用数字[0-9]表示!请重试...")
End If
End If
End Sub
-->
</script>
</head>
<body bgcolor="#ccffcc">
<form>
<%
' 注释:生成SQL查询语句
If Request("fid") <> "" Then 'fid是上个页面传过来的typeid号
where = "a.typeid='" & Request("fid") & "'"
ElseIF Request("title") <> "" Then
where = "a.title LIKE '%" & Request("title") & "%'"
ElseIF Request("author") <> "" Then
where = "a.author LIKE '%" & Request("author") & "%'"
ElseIF Request("ISBN") <> "" Then
where = "a.ISBN = '" & Request("ISBN") & "'"
Else
where = ""
End If
mysql = "SELECT a.ISBN, a.title AS btitle, a.author, a.price, " & _
"b.title AS ptitle " & _
"FROM book AS a JOIN Publisher AS b " & _
"ON PATINDEX('%-' + b.id + '-%',a.ISBN) > 0 "
If where <> "" Then mysql = mysql & "WHERE " & where

' 注释:连接数据库并执行SQL语句
Set objRS = Session("objRS")
objRS.Source = mysql
objRS.Open
' 注释:显示标题信息
outstr = "<font size=5 face=楷体_GB2312 color=red><b>"
If Request("type") <> "" Then
outstr = outstr & "当前图书分类:" & Request("type")
Else
outstr = outstr & "图书列表:"
End If
outstr = outstr & "</b></font>"
Response.Write(outstr)
' 注释:显示检索到的图书信息
outstr = ""
If objRS.RecordCount > 0 Then Response.Write("<table>")
For i = 1 To objRS.RecordCount
price = CSng(objRS("price"))
If i > 1 Then outstr = "<tr><td colspan=4>&nbsp;</td></tr>"
outstr = outstr & _
"<tr><td colspan=4>" & _
"<a href=detail.asp?ISBN=" & objRS("ISBN") & _
" target=_blank title=查看该图书的详细信息>" & _
"<font size=4 face=楷体_GB2312><b>" & objRS("btitle") & "</b>" & _
"</a></td></tr>" & _
"<tr>" &_
"<th>书号:</th><td>" & objRS("ISBN") & "&nbsp;&nbsp;</td>" & _
"<th>出版社:</th><td>" & objRS("ptitle") & "</td>" & _
"</tr><tr>" & _
"<th>作者:</th><td>" & objRS("author") & "</td>" & _
"<th>定&nbsp;&nbsp;价:</th><td>¥" & objRS("price") & "元</td>" & _
"</tr>" & _
"<tr><td colspan=4>" & _
"<font color=red>在线订购最低价:" & _
" 7折 " & price * 0.7 & "元" & _
" 您可节省" & price * 0.3 & "元" & _
"</font></td></tr>" & _
"<tr><td colspan=4>" & _
"<a href='#' onclick=" & Chr(34) & "DoOrder('" & _
objRS("ISBN") & ";" & _
objRS("btitle") & "')" & Chr(34) & _
"onmousemove=window.status='放入购物袋' onmouseout=window.status=''" & _
">放入购物袋" & _
"</a></td></tr>"
Response.Write(outstr)
outstr = ""
objRS.MoveNext
Next
If objRS.RecordCount > 0 Then
Response.Write("</table>")
Else
Response.Write("<p><b>还没有相关图书!</b>")
End If

' 注释:关闭数据记录集
objRS.Close
Set objRS = Nothing
%>
</form>
</body>
</html>

出错类型:ADODB.Recordset (0x800AOE79) 对象打开时不允许操作

黄色标记的程序能改成FROM book单表查询吗?只查book 的列,读不懂,该不了,1改就出错

改成mysql = "SELECT ISBN, title, author ,price FROM book where typeid = "Request('fid')" 对不对,99我

看不懂的还有红色标记

[此贴子已经被作者于2007-10-29 2:27:09编辑过]

搜索更多相关主题的帖子: ASP 购书 解释 
2007-10-29 02:17
快速回复:[求助]在线购书ASP程序,解释下程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028209 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved