注册 登录
编程论坛 ASP技术论坛

表达工出错?

中国男孩 发布于 2007-09-25 13:46, 1600 次点击


先首,祝各位大侠们<中秋节快乐>!
不知道我的这个程序出错,出错在哪里,请大侠们帮小弟解决:
出错信息如下:
Microsoft JET Database Engine '80040e14'

语法错误 (操作符丢失) 在查询表达式 '>=clng('') and <=clng('')' 中。

\wwwroot\cw\searh.asp, line 10

--------------------------------------------------------------------------------
Host by NetBox Version 2.8 Build 4128


原程序如果下:

<!--#Include File="linkdatamdb.asp"-->
<%

select1=request.querystring("select1")
t1=request.querystring("t1")
t2=request.querystring("t2")

set cwrs=server.createobject("ADODB.Recordset")
cwsql="select * from cw_data where "&select1&">=clng('"&t1&"') and "&select1&"<=clng('"&t2&"') Order By id asc"
cwrs.open cwsql,cwconn,1,1
if cwrs.recordcount<1 then
Response.Write "<script language=javascript>alert('对不起,没有找到你要找的内容!');self.location=(""show_data.asp"");</script>"
else

If Request.Querystring("dch_page")="" then
dch_page=1
Else
dch_page=clng(Request.Querystring("dch_page"))
End If
Cwrs.Pagesize=1
Cwrs.AbsolutePage=dch_page

%>
<tr>
<td>
<table border="0" width="100%" id="table4" style="border-collapse: collapse" bgcolor="#0066FF" cellpadding="0">
<tr>
<td>
<table border="1" width="100%" style="border-collapse: collapse" id="table5" height="26" bordercolor="#FFFFFF">
<tr>
<td width="82" align="center">进价</td>
<td width="93" align="center">出售价</td>
<td width="93" align="center">利润</td>
<td align="center">时间</td>
<td width="144" align="center">拿货地址</td>
<td width="192" align="center">注备</td>
</tr>
</table>
</td>
</tr>


<tr>
<td>
<table border="1" width="100%" style="border-collapse: collapse" id="table6" bordercolor="#FFFFFF">
<%for cw=1 to cwrs.pagesize
if cwrs.bof or cwrs.eof then exit for
%>
<tr>
<td width="82">
<p align="right"><b><font size="2"><%=cwrs("jj")%>¥</font></b></td>
<td width="93">
<p align="right"><b><font size="2"><%=cwrs("csj")%>¥</font></b></td>
<td width="93">
<p align="right"><b><font size="2"><%=cwrs("ly")%>¥</font></b></td>
<td width="135"><%=cwrs("year")%><%=cwrs("month")%><%=cwrs("day")%></td>
<form method="POST" action="">
<td>
<p align="center">
<textarea rows="1" name="S1" cols="13" style="border: 1px solid #0066FF; padding: 0; background-color:#0066FF"><%=cwrs("hour")%><%=cwrs("address")%></textarea></td>
<td width="192">
<p align="center">
<textarea rows="1" name="S2" cols="18" style="border: 1px solid #0066FF; background-color:#0066FF; padding-left:1px; padding-right:0; padding-top:0; padding-bottom:0"><%=cwrs("bz")%></textarea></td>
</form>
</tr>
<%
cwrs.movenext
next
end if
%>

</table>
</td>
</tr>
</table>
<p align="center">
<%
For zqy=1 To cwrs.PageCount
If zqy=dch_Page Then
Response.Write zqy &"&nbsp"
Else
Response.Write "<a href='searh.asp?dch_Page="&zqy&"'>"&zqy&"</a>" &"&nbsp"

End if
Next
%>
<select size="1" name="select" onchange="javascript:location=this.options[this.selectedIndex].value;">
<option value="第<%=dch_page%>页">第<%=dch_page%>页</option>
<%
for dch=1 to cwrs.pagecount
if dch<>dch_page then
%>
<option value=searh.asp?dch_page="<%=dch%>">第<%=dch%>页</option>
<%
end if
next
%>

</select> </p>
</td>
</tr>
<%
cwconn.close
set cwconn=nothing
%>

只有本站会员才能查看附件,请 登录

25 回复
#2
hmhz2007-09-25 13:52

where "&select1&">=clng("&t1&") and "&select1&"<=clng("&t2&")

[此贴子已经被作者于2007-9-25 13:59:05编辑过]

#3
中国男孩2007-09-25 14:03
怎么改呢?
#4
中国男孩2007-09-25 14:05

请问大侠怎么解决呢?

#5
hmhz2007-09-25 14:07
帮你改好了
where "&select1&">=clng("&t1&") and "&select1&"<=clng("&t2&")
#6
中国男孩2007-09-25 14:08
但是还是没对啊
#7
中国男孩2007-09-25 14:10

我按你的方法去做了:
但还是出现了这个的信息:
Microsoft JET Database Engine '80040e14'

语法错误 (操作符丢失) 在查询表达式 '>=clng() and <=clng()' 中。

\wwwroot\cw\searh.asp, line 10

#8
tianyu1232007-09-25 15:22


t1=request.querystring("t1")

t2=request.querystring("t2")

t1,t2可能取值为空或不是数字!

建议在此两句下面,加入语句检测一下:

t1=request.querystring("t1")

t2=request.querystring("t2")

response.write t1&t2

response.end

看输出的值是否为空或者是否是数字!

#9
中国男孩2007-09-25 15:29

大侠你好,我已经照你的方法,去做,向页面输出的是:数字:123
123123

#10
中国男孩2007-09-25 15:30
大侠,你可以下载我的源程序去看一下,
#11
yms1232007-09-25 15:41
cwsql="select * from cw_data where "&select1&">="&t1&" and "&select1&"<="&t2&" Order By id asc"
数字型在sql里不用转换直接用就可以。
#12
中国男孩2007-09-25 16:49

版主,但是我没有用clng()转之前,也出错了,所以,我就用clng转了,

#13
中国男孩2007-09-25 16:51

出错信息:

Microsoft JET Database Engine '80040e14'

语法错误 (操作符丢失) 在查询表达式 '>= and <=' 中。

\wwwroot\cw\searh.asp, line 11

--------------------------------------------------------------------------------
Host by NetBox Version 2.8 Build 4128

#14
hmhz2007-09-25 17:03
clng() 函数去掉 where "&amp;select1&amp;"=&gt;t1&amp;" and "&amp;select1&amp;"&lt;="&amp;t2&amp;"

[此贴子已经被作者于2007-9-25 17:05:59编辑过]


#15
中国男孩2007-09-25 17:17

还是一样的

Microsoft JET Database Engine '80040e14'

语法错误 (操作符丢失) 在查询表达式 'clng() 函数去掉 where => and <=' 中。

\wwwroot\cw\searh.asp, line 11

--------------------------------------------------------------------------------
Host by NetBox Version 2.8 Build 4128

#16
tianyu1232007-09-25 18:51

cwsql="select * from cw_data where "&select1&">=clng('"&t1&"') and "&select1&"<=clng('"&t2&"') Order By id asc"

在此句下面:

response.write cwsql

response.end

看看输出结果是什么?

"&select1&" 输出的是数据表中的字段吗?

#17
yms1232007-09-25 19:22

那就是查询页面没有提价过来内容。

#18
中国男孩2007-09-26 10:18

我已按照16楼的方法去做了:
输出来的是:121
342342select * from cw_data where jj>=clng('121') and jj<=clng('342342') Order By id asc

#19
中国男孩2007-09-26 10:20

好像,已经获取过来:"t1"和"t2"中的内容过来了
我原来程序在这里可以下载帮我去查一下:

只有本站会员才能查看附件,请 登录

#20
中国男孩2007-09-26 10:34

反正就是,当然搜索那个页,点<搜索>按钮,然后就传送到处理搜索那个页就去了,能显示,但当然选择 翻页时,就出现了这样的错误!

#21
gupiao1752007-09-26 14:09

你试着把CW_DATA表里的货币字段改为普通文本字段,在写入前或输出后再加上:$货币符号,这样查询应该可以!只是麻烦了些!

#22
gupiao1752007-09-26 14:18
说错了。是改为数字字段,不好意思!
#23
madpbpl2007-09-26 15:42
select1=request.querystring("select1")
t1=request.querystring("t1")
t2=request.querystring("t2")
改成
select1=request("select1")
t1=request("t1")
t2=request("t2")
主要还是向前们一些朋友说的你的值没有传过来,再把查询条件加到分页函数里。
还有不明白你写两个搜索干什么?如果写成两个搜索,你要判断一下传过来的值,
然后确定到底用哪个条件进行搜索,同样把查询条件要加到分页函数里。
#24
中国男孩2007-09-26 17:23
楼上的大侠,
全部程序在这里,你们下载下去去帮我看一下:
只有本站会员才能查看附件,请 登录

#25
中国男孩2007-09-26 17:39
我是asp初学者   
#26
gupiao1752007-09-27 10:34

晕,一发发这么多的文件,你把出问题的ASP文件以及相关的文件发出来就可以了.

1