简体   繁体   English

类型不匹配错误到经典ASP中的ceil函数

[英]type missmatch error to ceil function in classic asp

    sql_logcout="select count(*) as totcount from tbllogincount where companylogin='"&RECRS("companylogin")&"' and (logindate>'"&fromdate&"' and logindate<'"&todate&"') "
    rslogins.open sql_logcout,con,0,3
    if not rslogins.EOF then
      totlogins=rslogins("totcount")
      do while not rslogins.EOF 

        'on below line i am getting error
        avglogin=ceil(totlogins/10)
        avglogin=ceil(avglogin)

        rslogins.movenext
      loop
    end if
    rslogins.close      

    avglogin=ceil(totlogins/10)
    avglogin=ceil(avglogin)

    rslogins.movenext
  loop
end if
rslogins.close

in above code I get count 0 and I am getting error on avglogin=ceil(totlogins/10) 在上面的代码中,我得到计数​​0,并且在avglogin=ceil(totlogins/10)上出现错误

error is as below 错误如下

Microsoft VBScript runtime error '800a000d' Microsoft VBScript运行时错误'800a000d'

Type mismatch 类型不匹配

/admin/member_email.asp, line 200 /admin/member_email.asp,第200行

What is the problem there? 那里是什么问题? I had tried by using CStr or CInt but still its same. 我曾经尝试过使用CStrCInt但仍然相同。 Please help me to solve this error. 请帮助我解决此错误。 I am using Classic ASP with MySQL. 我将MySQL与经典ASP一起使用。

You simply need to ensure that there's a value in the data you're reading from your tables. 您只需要确保从表中读取的数据中有一个值即可。

Try: 尝试:

If Not IsNull(rslogins("totcount")) And Not rslogins("totcount") Is Nothing Then
    Do While ...
        ....
    Loop
End If

Personally, I prefer the quick and the dirty method of a quick cast, but I'm sure someone will spurn me for it... 就个人而言,我更喜欢快速和肮脏的快速投射方法,但是我敢肯定有人会因此而拒绝我...

If rslogins("totcount") & "" <> "" Then
    ....
End If

It's your choice! 这是你的选择!

Background reading: 背景阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM