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

我就纳闷了其他调用都可以为什么这一个参数就不能!气死我了!

d778 发布于 2007-10-28 22:55, 941 次点击

<%

set rs=server.createobject("adodb.recordset")
sql="select top 1 * from qqq"
rs.open sql,conn,1,1

fei1=rs("fei1")
fei2=rs("fei2")
yang1=rs("yang1")

%>
<tr><td height="30" colspan="8" align="right">
<p style="line-height: 150%; margin-left:5px; margin-right:15px; margin-top:5px; margin-bottom:5px">

<%=yang1%>
<%if totalcash< yang1 then%>
價格總計:<%=totalcash*fei2%>元
<%end if%>
<%if totalcash> yang1 then%>
由于您购买的金额超过<%=yang1%>元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>元
<%end if%>

代码如上
问题如下
fei1
fei2 在下面都没有问题 都可以得出!
但是关键的yang1 在红色位置 就可以显示数值!为什么在下面totalcash< yang1 totalcash> yang1就不可以呢???是空的! 我是大于小于的算法 大于则 小于……

我不让它读数据库就可以(数据库里绝对没有问题因为 上面红色位置都可以读出“3000”)
这样写 不读数据库就可以 不过要先定义

<%yang1=3000%>
<%if totalcash< yang1 then%>
價格總計:<%=totalcash*fei2%>元
<%end if%>
<%if totalcash> yang1 then%>
由于您购买的金额超过<%=yang1%>元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>元
<%end if%>

难道是totalcash> yang1这个问题 应该不会啊!!!!fei1 fei2都可以啊?!!弄几天了也不会头都大了

来麻烦大家 帮下我!

18 回复
#2
d7782007-10-28 22:58
应为我要让yang1读数据库里的参数的!!!
单独调用都没有问题!
就是 > <大于小于号这里 就不成


yang1 fei1 totalcash 都是数字





难道没人 帮我嘛? 我还在等!!!帮帮我 先谢谢大家!希望帮小弟个忙!
我很急 不然今天都睡不着!总想怎么解决

[此贴子已经被作者于2007-10-28 23:44:37编辑过]

#3
hmhz2007-10-29 00:47
你的 totalcash 是哪来的?没看你上面带下来啊
#4
d7782007-10-29 08:54
都没有错!写<%yang1=3000%>的话就可以
totalcash 是上面数据里的!已经读数据没有问题!不用考虑 totalcash的问题

[此贴子已经被作者于2007-10-29 9:08:25编辑过]

#5
shaoli42612007-10-29 10:19
那就用cint函数转化成数字看看~~   我不知道~  只是建议~~~~
#6
madpbpl2007-10-29 10:21
yang1=cint(yang1)

yang1=clng(yang1)
试试
#7
d7782007-10-29 12:06
<%if totalcash<cint(yang1) then%>
错误<%=totalcash*fei2%>
<%end if%>
<%if totalcash>cint(yang1) then%>
由于您购买的金额超过3000元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>
<%end if%>


是这样写吗?
不行啊 还是!
#8
hmhz2007-10-29 12:11
yang1 字段什么类型的,如果是文本类型的,就改成数字类型的 int

还有 totalcash 也是 计算的数据类型必须都是数字类型 ,否则就要用函数转换成数字类型,但这样转换是不明智的选择

[此贴子已经被作者于2007-10-29 12:14:15编辑过]

#9
tianyu1232007-10-29 12:14
<%if cint(totalcash)<cint(yang1) then%>
错误<%=totalcash*fei2%>
<%end if%>
<%if cint(totalcash)>cint(yang1) then%>
由于您购买的金额超过3000元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>
<%end if%>
#10
yms1232007-10-29 12:54

到第几个判断出问题了?

#11
d7782007-10-29 12:55

楼上的 朋友 这个方法不可以啊
<%
set rs=server.createobject("adodb.recordset")
sql="select top 1 * from qqq"
rs.open sql,conn,1,1

fei1=rs("fei1")
fei2=rs("fei2")
yang1=rs("yang1")


%><tr><td height="30" colspan="8" align="right">
<p style="line-height: 150%; margin-left:5px; margin-right:15px; margin-top:5px; margin-bottom:5px">價格總計:<%=totalcash%>元


<%if cint(totalcash)<cint(yang1) then%>
错误<%=totalcash*fei2%>
<%end if%>
<%if cint(totalcash)>cint(yang1) then%>
由于您购买的金额超过3000元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>
<%end if%>
还是不行

[此贴子已经被作者于2007-10-29 12:56:42编辑过]

#12
tianyu1232007-10-29 13:03
<%
response.write"totalcash的值为:"& totalcash &"<br>"
response.write"yang1的值为:"& yang1
response.end
%>

<%if cint(totalcash)<cint(yang1) then%>
错误<%=totalcash*fei2%>
<%end if%>
<%if cint(totalcash)>cint(yang1) then%>
由于您购买的金额超过3000元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>
<%end if%>

在这个代码上面写上测试语句看一下结果!
#13
d7782007-10-29 13:11

yms123 回答: 都有问题 就是yang1 这个不能用!
但是不放>< 号里 单<%=yang1%>是有数据的!数据库中数据为3000

现在只要< >号调用yang1的就不行
但是我不用数据库 直接定义:yang1="3000"就可以!!下面判断就正确

#14
d7782007-10-29 13:17
以下是引用tianyu123在2007-10-29 13:03:04的发言:
<%
response.write"totalcash的值为:"& totalcash &"<br>"
response.write"yang1的值为:"& yang1
response.end
%>

<%if cint(totalcash)<cint(yang1) then%>
错误<%=totalcash*fei2%>
<%end if%>
<%if cint(totalcash)>cint(yang1) then%>
由于您购买的金额超过3000元,则享受我们98折。您实际应付价格<%=totalcash*fei1%>
<%end if%>

在这个代码上面写上测试语句看一下结果!

回复您
测试结果为
totalcash的值为3570
yang1的值为:3000

[此贴子已经被作者于2007-10-29 13:18:04编辑过]

#15
d7782007-10-29 13:20
好了!!!谢谢大家!一直的支持!帮助!
谢谢!!!

能告诉我cint干什么用的吗?
#16
gupiao1752007-10-29 17:07
cint(数据)是将红色部分的数据转换为数字类型的内置函数!

看来楼主还得加油啊,这个函数可是ASP里很基本的东西!
#17
d7782007-10-29 19:24
呵呵 谢谢你啊! 我太明白 你有没有这些 函数的 表给我看看啊!我也了解下 还有那些函数!

听楼上的说这种转换不好!
是不是我要把数据库里的 文本 改成 数字的 就不用函数转了呢?
#18
hmhz2007-10-30 01:57
是的,所以说,数据库设计很重要,数据库设计的好,走的都是直路,不需要写一大对程序或函数来控制,程序多了,函数多了,就会让程序运行的效率降低
#19
yms1232007-10-30 09:22

可能yang1没有得到数据

1