请教一条sql语句!

smile9961 2004-04-16 04:20:10
在一个带有翻页链接的显示查询结果页面,点了“下一页”链接就提示出错。MicrosoftOLEDBProviderforODBCDrivers(0x80040E14)-->sql语句出错(字段名错误,或数据类型不匹配)

现在知道原因是page=2页面sql语句中参数为空。
我用的sql语句是:

sql="select "&types&" from "&tablename&" where "&types&" like '%"&keyword&"%' "

其中tablename是个session变量,types,keyword由前一页面的form得到。
请问该怎么来改呢?
...全文
93 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
dotnet东哥 2004-04-19
  • 打赏
  • 举报
回复
filename=request("filename")
types=request("types")
keyword=request("keyword")
dotnet东哥 2004-04-19
  • 打赏
  • 举报
回复
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
/question/modify4.asp, 第 37 行????
itsing 2004-04-19
  • 打赏
  • 举报
回复
晕~
onclick="location='aaa.asp?types=<%=request("types")%>&keyword=<%=request("keyword")%>&page=<%=page+1%>"'
itsing 2004-04-19
  • 打赏
  • 举报
回复
onclick="location='aaa.asp?types=<%=request("types")%>&keyword=<%=request("keyword")%>'&page=<%=page+1%>"
itsing 2004-04-19
  • 打赏
  • 举报
回复
<input type=button value=下一页 onclick="lacation='aaa.asp?types=<%=request("types")%>&keyword=<%=request("keyword")%>'&page=<%=page+1%>">

在页面头部,你接收数据的处理要是
types=request("types")
而不是types=request.form("types")
  • 打赏
  • 举报
回复
你在search.asp中设定两个hidden域然后hidden的值分别为request.form("types")和request.form("keyword")
  • 打赏
  • 举报
回复
so long~~

page=1与page=2其实就是不同的页面了,当第一页的时候可以获得request.form("types"),但是到第二页的时候就已经没有了,所以你需要在url中指定或者再次通过hidden域或者session变量等实现获得该参数

smile9961 2004-04-18
  • 打赏
  • 举报
回复
为什么这样的sql语句:
sql="select "&types&" from "&tablename&" where "&types&" like '%"&keyword&"%' "
在带有page=2时不能传递参数????

请高手们多多指点啊。
smile9961 2004-04-18
  • 打赏
  • 举报
回复
问题就在这里,为什么第二页就不能得到参数呢,又如何让它得到呢???
liuyangxuan 2004-04-16
  • 打赏
  • 举报
回复
在你的分页的链接上加上:&您的参数。
smile9961 2004-04-16
  • 打赏
  • 举报
回复
display.asp
-------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<html>
<body>
<%
tablename=session("tablename")
filename=request.Form("filename")
types=request.Form("types")
keyword=request.Form("keyword")

sql="select "&types&" from "&tablename&" where "&types&" like '%"&keyword&"%'" 'sql语句是正确的
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,3

if rs.eof or rs.bof then
response.Redirect("null.asp?filename=")&filename
else
%>
<table width="500" align="center" >
<tr>
<td height="30" colspan="3" >以下是您所要的记录</td>
</tr>
<tr>
<td colspan="3">
<!--#include file="page.asp"--> '引用page.asp
<%
rs.PageSize=4
' 设置单页的数据记录数
iPageCount=rs.PageCount
' 定义了一个页码数量的变量
If Len(Request.QueryString("Page"))=0 Then
CurPage=1
Else
CurPage=CInt(Request.Querystring("Page"))
End If
' 得到当前的页码
rs.AbsolutePage=CurPage
' 设置记录集中的当前页
' 开始调用显示翻页的函数,显示页数栏
' 函数原型:ShowPageBar(TotalPage,CurPage,strUrl)
strUrl="modify4.asp"
' 定义连接的URL,可以用我们自己的页面地址
ShowPageBar iPageCount,CurPage,strUrl
' 调用完成
%>

<%
DIM i
i=1
DIM strcontent
strcontent=rs(""&types&"")
strcontent=left(strcontent,5) '截取字符
%>
</td ></tr>
<tr>
<td width="80" height="30">编号</td>
<td>开头部分</td>
<td width="80">操作</td>
</tr>
<%
for recordnums=1 to rs.pagesize
%>
<tr>
<td><%=i%></td>
<td><%=strcontent%>...</td>
<td>修改</td>
</tr>
<%
i=i+1
rs.movenext
if rs.eof then
exit for
end if
next
%>
</table>
</body>
</html>

<%
SET rs=NOTHING
conn.Close
SET conn=NOTHING
end if
%>
smile9961 2004-04-16
  • 打赏
  • 举报
回复
是啊,我也知道啊,可是具体该怎么来传递呢,请大家指点啊。
<!--#include file="page.asp"-->
中是个翻页函数,应该没错的啊,请大家看看。
page.asp
--------------------------------

<%
Sub ShowPageBar(TotalPage,CurPage,strUrl)
' 参数TotalPage:全部页数;CurPage:当前页数;strUrl:翻页使用的连接地址

DIM strPage
CurPage=GetValidPageNO(TotalPage,CurPage)
Response.Write "<TABLE bgcolor=#cc0000 align=center>"
Response.Write "<TR><td align='center'>"
Response.Write "<font size=2 color=white>页数:" & CurPage & "/" & TotalPage & " </font>"
IF InSTR(strUrl,"?")=0 THEN
strPage="?Page="
ELSE
strPage="&Page="
END IF

IF Curpage>1 THEN
Response.Write "<font size=2 ><a href=" & strUrl &strPage&"1><font size=2 > [第一页]</fnot></a>"
ELSE
Response.Write "<font size=2 > [第一页]</fnot>"
END IF

IF CurPage>=2 THEN
Response.Write "<a href=" & strUrl & strPage &CurPage-1&"><font size=2 > [上一页]</fnot></a>"
ELSE
Response.Write "<font size=2 > [上一页]</fnot>"
END IF

IF cInt(CurPage)<cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage &CurPage+1&"><font size=2 > [下一页]</fnot></a>"
ELSE
Response.Write "<font size=2 > [下一页]</fnot>"
END IF

IF cInt(CurPage) <>cInt(TotalPage) THEN
Response.Write "<a href=" & strUrl & strPage & TotalPage&"><font size=2 > [最末页] </fnot></a>"
ELSE
Response.Write "<font size=2 > [最末页] </fnot>"
END IF
Response.Write "</TD></tr></table>"
END SUB

Function GetValidPageNo(PageCount,CurPage)
Dim iPage
iPage=CurPage
IF cInt(CurPage)<1 THEN
iPage= 1
END IF
IF cInt(iPage) > cInt(PageCount) THEN
iPage= PageCount
END IF
GetValidPageNo=iPage
END Function
%>

--------------------------------
kellychenjt 2004-04-16
  • 打赏
  • 举报
回复
在第二页你需要传参数types,tablesname,keyword,currentpage才可以
ss4ss 2004-04-16
  • 打赏
  • 举报
回复
要对数据集进行分页处理
然后按页输出
smile9961 2004-04-16
  • 打赏
  • 举报
回复
我按楼上兄弟说的试了,这样连第一页都看不到了。
应该不是sql语句的错误,只是page=2中sql语句中没得到参数!

如何让page=2页面得到参数呢?
同一问题另一链接http://expert.csdn.net/Expert/topic/2971/2971932.xml?temp=.5564081
回复有分,欢迎大家踊跃发表意见!
yslcuk 2004-04-16
  • 打赏
  • 举报
回复
sql="select '"&types&"' from '"&tablename&"' where '"&types&"' like
'%"&keyword&"%' "

28,404

社区成员

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

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