ASP搜索问题 [英] ASP Search problem

查看:53
本文介绍了ASP搜索问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想知道是否有人可以帮我这个 - 这原本是一个简单的

搜索例程,将结果返回给自己!

试图变得聪明我试图结合不。每页的项目,所以我可以

显示有限的项目...


好​​的问题!一切似乎没关系,除非它没有返回结果,

当我知道它应该

SQL字符串似乎没问题,如果我删除搜索条件

处理程序然后它有点工作但仍然不对!


任何人都可以告诉我问题出在哪里 - 非常感谢。


提前致谢


Lee


<%


如果Request.QueryString (order)=""然后

StrOrder =" p.prodCode"

否则

StrOrder = Request.QueryString(" order")

结束如果

Const adOpenKeyset = 1

Const adLockReadOnly = 1


set conn = server.createobject(" ADODB.Connection")

set rs = server.createobject(" ADODB.Recordset")

conn.open" TTMYDB"


函数FormatStr(String)

on Error resume next

String = Replace(String,CHR(13),"")

String = Replace(String,CHR(10)& CHR(10),"< / P>< P>")

String = Replace( String,CHR(10),"< BR>")

FormatStr = String

结束功能


如果Request.QueryString(" mode")=" doit"然后

keywords = split(Request.Form(" search"),"")

boolthing = true

sql =" ;选择不同的p.prodCode,p.prodName,p.productDesc,c.catalogName,
p.productPrice,c.catalogID from products p,catalogs c where

p .catalogID = c.catalogID order by &安培; StrOrder


关键字中的每个单词

如果boolthing那么

boolthing = false

sql = sql& "和("

else

sql = sql&"或者"

结束如果


sql = sql&" p.prodName like''%"& word&"%''"

sql = sql&"或p。 productDesc像''%'& word&"%''"

sql = sql&"或p.prodCode like''%"& word&" ;%''"

sql = sql&"或c.catalogName like''%"& word&"%''"

next

sql = sql&")"


Response.Write Sql

rs。打开sql,conn,adOpenKeyset,adLockReadOnly


如果rs.EOF或rs.BOF那么

Response.Write找不到会员

Else

TotalRows = rs.RecordCount

rs.PageSize = 2

PageSize = rs.PageSize

TotalPages = RS.PageCount


选择案例请求(移动)

案例"第一及QUOT; pageNo = 1''首先

case" prev" pageNo = cint(Session(" page_num")) - 1''Next

case" next" pageNo = cint(Session(" page_num"))+ 1''上一页

case" last" pageNo = TotalPages''最后

案例否则PageNo = 1

结束选择


如果cint(PageNo)< 1然后PageNo = 1

如果cint(PageNo)> TotalPages然后pageNo = TotalPages


RS.AbsolutePage = PageNo

PageNumber = PageNo

会话(" page_num")= PageNo

Response.Write"< td>"


HowMany = 0

直到rs.EOF或HowMany = > PageSize

Response.Write"< h1> Item:< a href =''productresult.asp?strprodCode =''" &

rs(" prodCode")& "''>"

Response.Write"< b>" &安培; rs(prodCode)& " - &安培; rs(prodName)& "< / a>< / b>"

Response.Write

"< br>& nbsp;& nbsp;& nbsp ;& nbsp;& nbsp;& nbsp;& nbsp;& nb sp;& nbsp;此产品是

& pound;"

Response.Write""

rs.MoveNext

howmany = howmany + 1

loop

回复。写

结束如果


%>< / td>

<%end if if>

Hi, wonder if anyone can help me with this - This was originally a simple
search routine returning results back to itself!
Trying to be smart I tried to combine a no. items per page so I could
limited items displayed...

Okay problem! everything seems to be okay except it is returning no results,
when I know it should
the SQL string appears to be okay and if I remove the search criteria
handlers then it kinda works but still not right!

Can anyone tell me where the problem is - would be greatly appreciated.

Thanks in advance

Lee

<%

if Request.QueryString("order") = "" then
StrOrder = "p.prodCode"
Else
StrOrder = Request.QueryString("order")
End if
Const adOpenKeyset = 1
Const adLockReadOnly = 1

set conn = server.createobject("ADODB.Connection")
set rs = server.createobject("ADODB.Recordset")

conn.open "TTMYDB"

Function FormatStr(String)
on Error resume next
String = Replace(String, CHR(13), "")
String = Replace(String, CHR(10) & CHR(10), "</P><P>")
String = Replace(String, CHR(10), "<BR>")
FormatStr = String
End Function

If Request.QueryString("mode") = "doit" then
keywords = split(Request.Form("search"), " ")
boolthing = true
sql = "select distinct p.prodCode, p.prodName, p.productDesc, c.catalogName,
p.productPrice, c.catalogID from products p, catalogs c where
p.catalogID=c.catalogID order by " & StrOrder

for each word in keywords
if boolthing then
boolthing=false
sql = sql & "and ("
else
sql = sql & "or"
end if

sql = sql & " p.prodName like ''%" & word & "%'' "
sql = sql & "or p.productDesc like ''%" & word & "%'' "
sql = sql & "or p.prodCode like ''%" & word & "%'' "
sql = sql & "or c.catalogName like ''%" & word & "%'' "

next
sql = sql & ")"

Response.Write Sql
rs.open sql, conn, adOpenKeyset, adLockReadOnly

if rs.EOF or rs.BOF then
Response.Write "No Members Found"
Else
TotalRows = rs.RecordCount
rs.PageSize = 2
PageSize = rs.PageSize
TotalPages=RS.PageCount

select case Request("move")
case "first" pageNo = 1 '' First
case "prev" pageNo = cint(Session("page_num")) - 1 '' Next
case "next" pageNo = cint(Session("page_num")) + 1 '' Previous
case "last" pageNo = TotalPages '' Last
case Else PageNo = 1
End Select

if cint(PageNo) < 1 then PageNo = 1
if cint(PageNo) > TotalPages then pageNo = TotalPages

RS.AbsolutePage = PageNo
PageNumber=PageNo
Session("page_num") = PageNo
Response.Write "<td>"

HowMany = 0
Do until rs.EOF or HowMany => PageSize

Response.Write "<h1>Item: <a href=''productresult.asp?strprodCode=''" &
rs("prodCode") & "''>"
Response.Write "<b>" & rs("prodCode") & " - " & rs("prodName") & "</a></b>"
Response.Write
"<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;&nbsp;This product is
&pound;"
Response.Write ""
rs.MoveNext
howmany = howmany + 1
loop
Response.Write " "
End if

%></td>
<% end if %>

推荐答案

已经在.db中回答了


请不要多件李。这绝对是一个与数据库相关的问题,因此.asp.db是发布它的完美组合。在这里张贴

并没有增加你得到答案的机会(我们大多数人都会订阅这两个团队的
)。相反,如果有人花了他的时间

在这里回答它,只是发现它已经在其他

组中解决了,那个人可能已经生气了足以忽略你未来的任何帖子

,从而减少你将来获得帮助的机会。


有时你不确定哪个小组是最合适的

(再次,这不是其中之一),你会想要向两个小组发布一个问题

。在这种情况下,您应该使用交叉发布技术,

而不是发布相同消息的多个发布。要进行交叉发布,请将

一个以分号分隔的新闻组列表添加到你的帖子的To:标题中,然后发布一次。它以及对它的任何回复,

将出现在列表中的所有新闻组中。所以,如果我在.asp.db回复,

我的回复也会出现在.asp.general。


Bob Barrows

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件
Already answered over in .db

Please do not multipost Lee. This is definitely a database-related
question so .asp.db was the perfect group in which to post it. Posting it
here as well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his time
to answer it here, only to find that it was already resolved in the other
group, that person may have been annoyed enough to ignore any future posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most appropriate
(again, this was not one of them), and you will want to post a question to
both groups. In that situation, you should use the cross-posting technique,
rather than posting multiple postings of the same message. To crosspost, put
a semicolon-delimited list of the newsgroups to which you wish to post in
the To: header of your post and post it once. It, and any replies to it,
will appear in all the newsgroups in your list. So, if I reply in .asp.db,
my reply will also appear here in .asp.general.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


Bob Barrows于2003年11月15日在

microsoft.public.inetserver.asp.general:
Bob Barrows wrote on 15 nov 2003 in
microsoft.public.inetserver.asp.general:
要交叉发布,请将以分号分隔的新闻组列表添加到
To crosspost, put a semicolon-delimited list of the newsgroups to
which you wish to post in




" semicolon-delimited":这取决于所使用的usenet-client。


-

Evertjan。

荷兰。

(请在我的电子邮件地址中将x'变为点数)



"semicolon-delimited": this depends on the usenet-client used.

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


Evertjan。写道:
Evertjan. wrote:
鲍勃巴罗斯于2003年11月15日在
microsoft.public.inetserver.asp.general写道:
Bob Barrows wrote on 15 nov 2003 in
microsoft.public.inetserver.asp.general:
要交叉插入,请以分号分隔列表要发布的新闻组
To crosspost, put a semicolon-delimited list of the newsgroups to
which you wish to post in



分号分隔:这取决于所使用的usenet-client。



"semicolon-delimited": this depends on the usenet-client used.




好​​的,我会修改的。有什么建议吗?

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

无垃圾邮件



OK, I''ll amend that. Any suggestions?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


这篇关于ASP搜索问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆