|
蓝森林 http://www.lslnet.com 2006年8月25日 8:28
[急!]分页问题!大家帮帮忙看一下吧
我在做分页时遇到了这样的问题当用如下代码时,请大家耐心看一下。
<%scn=request.servervariables("script_name")
if request("page")="" then page=1 else page=cint(request("page"))
set objconn=server.createobject("adodb.connection")
objconn.open "dsn=search;uid=sa;pwd=2252973"
set objrs=server.createobject("adodb.recordset")
objrs.cursorlocation=adUseClient
objrs.cursortype=adOpenStatic
objrs.cachesize=pagesize
if Request.Form("keyword")<>"" then session("keyword")=Request.Form("keyword")
if request.form("keysort")<>"" then session("keysort")=request.form("keysort")
strQ="select * from "
strQ=strQ&"table_india where left(hscode,6)='"&session("keyword")&"'"
objrs.open strQ,objconn, , , adcmdtext
m=objrs.recordcount
objrs.pagesize=pagesize
totalpages=objrs.pagecount
if not(objrs.eof) then
objrs.absolutepage = page
end if
%>
可以实现分页查询
但是把"if Request.Form("keyword")<>"" then session("keyword")=Request.Form("keyword")
if request.form("keysort")<>"" then session("keysort")=request.form("keysort")
strQ="select * from "
strQ=strQ&"table_india where left(hscode,6)='"&session("keyword")&"'"
变成如下代码时就不能用了
"if Request.Form("keyword")<>"" then session("keyword")=Request.Form("keyword")
if request.form("keysort")<>"" then session("keysort")=request.form("keysort")
strQ="select * from "
select case strQcountry
case 1
strQ=strQ&"TABLE_CHINA "
case 2
strQ=strQ&"TABLE_KOREA "
case 3
strQ=strQ&"TABLE_INDIA "
case 4
strQ=strQ&"TABLE_ARGENTINA "
case 5
strQ=strQ&"TABLE_CHILE "
case 6
strQ=strQ&"TABLE_URUGUAY "
case 7
strQ=strQ&"TABLE_PERU "
end select
strQ=strQ&"where left(hscode,6)='"&session("keyword")&"'"
请问是什么原因?大家帮帮忙 |
为什么没有回答啊 是不是代码太多看起来比较烦啊 |
9494,那么多,你最好用自然语言来表达,这样便于大家观赏嘛... |
strQ="select * from "
select case strQcountry
case 1
strQ=strQ&" TABLE_CHINA "
case 2
strQ=strQ&" TABLE_KOREA "
case 3
strQ=strQ&" TABLE_INDIA "
case 4
strQ=strQ&" TABLE_ARGENTINA "
case 5
strQ=strQ&" TABLE_CHILE "
case 6
strQ=strQ&" TABLE_URUGUAY "
case 7
strQ=strQ&" TABLE_PERU "
end select
strQ=strQ&" where left(hscode,6)='"&session("keyword")&"'"
在每个&"后空一格试试,在测试程序时,最好把SQL语句输出来看看 |
试了,但是仍有where附近有错误的提示 sql语句也检查了 没问题 我想在字SQL字符串连接中不能用select 语句啊 |
提示where附近有错,应该是SQL语句有问题,你确定浏览器输出的SQL没错吗? |
我用了你建议的方法,还有改掉了用错了的变量,最后问题解决了。谢谢你的帮助 |
我用了你建议的方法,还有改掉了用错了的变量,最后问题解决了。谢谢你的帮助 |
|